python 传参 getopt使用方式

2022-05-14 13:43:15 浏览数 (2)

def usage(): pass try: options,args = getopt.getopt(sys.argv[1:],"ht:m:a:",["help","type=","message=","agentid="]) except Except as e: print(e) a=1000002 t=None m=None for name,value in options: if name in ("-h","--help"): usage() elif name in ("-t","--type"): t=value elif name in ("-m","--message"): m=value elif name in ("-a","--agentid"): a=value else: usage()

0 人点赞