background image
argparse 是 python 标准库里面的用来处理命令行参数的库
位置参数和选项参数
先了解位置参数和选项参数的概念,以
linux 中’ls’命令为例
[root@openstack_1 /]# ls
bin
boot
dev
etc
home
lib
lost+found media
mnt
opt
pro
c
root
sbin
selinux
srv
sys tmp
usr
var
[root@openstack_1 /]# ls root/
anaconda-ks.cfg
devstack
index.html
install.log
install.log.
syslog
[root@openstack_1 /]# ls -l
总用量 86
dr-xr-xr-x.
2 root root
4096 4 月
1 22:42 bin
dr-xr-xr-x.
5 root root
1024 4 月
1 22:43 boot
drwxr-xr-x.
18 root root
3880 4 月
6 15:24 dev
drwxr-xr-x.
77 root root
4096 4 月
6 15:24 etc
drwxr-xr-x.
3 root root
4096 4 月
2 20:50 home
dr-xr-xr-x.
15 root root 12288 4 月
1 22:42 lib
drwx------.
2 root root 16384 3 月
26 20:59 lost+found
drwxr-xr-x.
2 root root
4096 9 月
23 2011 media
drwxr-xr-x.
2 root root
4096 9 月
23 2011 mnt
drwxr-xr-x.
3 root root
4096 4 月
2 21:03 opt
dr-xr-xr-x. 128 root root
0 4 月
6 2015 proc
dr-xr-x---.
5 root root
4096 4 月
2 21:05 root
dr-xr-xr-x.
2 root root 12288 4 月
1 22:42 sbin
drwxr-xr-x.
7 root root
0 4 月
6 2015 selinux
drwxr-xr-x.
2 root root
4096 9 月
23 2011 srv
drwxr-xr-x.
13 root root
0 4 月
6 2015 sys
drwxrwxrwt.
3 root root
4096 4 月
6 15:24 tmp
drwxr-xr-x.
12 root root
4096 3 月
26 21:03 usr
drwxr-xr-x.
18 root root
4096 3 月
26 21:04 var
1
2
3
4
5