操作系统服务相关知识详解
1. 命令行选项解析示例
在UNIX系统中,通过以下交互式会话展示命令行选项解析的工作方式:
% python foo.py -h
usage: foo.py [options]
options:
-h, --help show this help message and exit
-t
-o OUTFILE, --outfile=OUTFILE
-d DEBUG, --debuglevel=DEBUG
--speed=SPEED
--coord=COORD
--novice
--guru
当执行 python foo.py -t -o outfile.dat -d 3 --coord 3 4 --speed=ludicrous blah 时,输出结果如下:
tracing : True
outfile : outfile.dat
debug : 3
speed : ludicrous
coord : (3, 4)
mode : novice
args : ['blah']
若执行 python foo.py --speed=insane ,会出现错误提示:
usage: foo.py [options]
foo.py:erro
超级会员免费看
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



