1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
import argparse
def (): parser = argparse.ArgumentParser(usage="%(prog)s [options]",add_help=False, formatter_class=argparse.RawDescriptionHelpFormatter, description=(''' Please do not mess up this text! -------------------------------- I have indented it exactly the way I want it''')) other = parser.add_argument_group('Other arguments') other.add_argument('-h', '--help', action="store_true", help='help of the %(prog)s program') other.add_argument('--version', action='version', version='%(prog)s 1.0')
optional = parser.add_argument_group('optional arguments')
args=parser.parse_args() args = vars(args) if args['help']: parser.print_help() return args
Args = MY_Argparse() print Args
|
近期评论