python getopt 参数处理小示例 2020-02-16 分类:Python 标签Tags:python,getopt,参数,处理,示例,opts,args,sys,argv,t,s,h,walletype,servicename,help,a,o,walle,type
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 参数处理小示例】的全部内容了,欢迎留言评论进行交流!