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表示参数的全称,=表示后面需要传值
最后
以上就是神勇月饼最近收集整理的关于python getopt 参数处理小示例的全部内容,更多相关python内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复