python getopt 参数处理小示例

啊!洞庭湖的君山是多么雄伟壮观啊!就像一个忠诚的卫士守卫着洞庭湖,好让洞庭湖不受风雨的侵扰。一场小雨过后,出现了一道彩虹,就像一座美丽七彩桥。
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 getopt 参数处理小示例请关注haodaima.com其它相关文章!

标签: python getopt