python getopt 参数处理小示例
更新时间:2009年06月09日 23:43:45 作者:
getopt是python中专门用来处理参数的一个模块,十分好用,下面提供一个小示例
opts, args = getopt.getopt(sys.argv[1:], "t:s:h", ["walletype=", "servicename=",'help'])
for a,o in opts:
if a in ('-t', '--walletype'):
walle_type = o
elif a in ('-s', '--servicename'):
service_name = o
elif a in ('-h', '--help'):
help = True
其中t:s:h表示参数的缩写,:表示参数后需要传值
walletype=,servicename=,help表示参数的全称,=表示后面需要传值
for a,o in opts:
if a in ('-t', '--walletype'):
walle_type = o
elif a in ('-s', '--servicename'):
service_name = o
elif a in ('-h', '--help'):
help = True
其中t:s:h表示参数的缩写,:表示参数后需要传值
walletype=,servicename=,help表示参数的全称,=表示后面需要传值
相关文章
python中数组array和列表list的基本用法及区别解析
大家都知道数组array是同类型数据的有限集合,列表list是一系列按特定顺序排列的元素组成,可以将任何数据放入列表,且其中元素之间没有任何关系,本文介绍python中数组array和列表list的基本用法及区别,感兴趣的朋友一起看看吧2022-05-05


最新评论