前言
老大给我写了个简单的框架,里面用到了getopt模块,一开始很懵逼,研究后日常记录下这个模块。
函数原型
getopt.getopt(args, shortopts, longopts=[])
参数解释
args: 指的是当前脚本接收的参数,它是一个列表,可以通过sys.argv获得
shortopts 是短参数 啥叫短参数啊?参数名短 类似于 这样:python test.py -h # 输出帮助信息
longopts 是长参数 啥叫长参数啊?参数名长 类似于 这样:python test.py -help # 输出帮助信息
函数返回值
opts:分析出的(option, value)列表对
args:不属于格式信息的剩余命令行参数列表。