Print program usage example with argparse module

前端 未结 1 702
北海茫月
北海茫月 2021-02-05 00:24

I am trying to learn how to use python\'s argparse module. Currently my python script is:

parser = argparse.ArgumentParser(description=\'My first ar         


        
相关标签:
1条回答
  • 2021-02-05 00:52

    Use parser.epilog to display something after the generated -h text.

    parser = argparse.ArgumentParser(
        description='My first argparse attempt',
        epilog='Example of use')
    
    output = parser.parse_args()
    

    prints:

    My first argparse attempt
    
    optional arguments:
      -h, --help  show this help message and exit
    
    Example of use
    
    0 讨论(0)
提交回复
热议问题