Python argparse: Make at least one argument required

前端 未结 11 1740
谎友^
谎友^ 2020-12-13 01:39

I\'ve been using argparse for a Python program that can -process, -upload or both:

parser = argparse.ArgumentParser(de         


        
11条回答
  •  北荒
    北荒 (楼主)
    2020-12-13 01:49

    if not (args.process or args.upload):
        parser.error('No action requested, add -process or -upload')
    

提交回复
热议问题