Something that conveniently captures arguments.
Whether it's help, specifying argument types, default values, or even trying to design it yourself, the more convenient it is, the more complicated it is to use.
So, I relied on this area to investigate and use only the minimum rules.
parser = argparse.ArgumentParser(description='Create Test data') #make parser
parser.add_argument('target', type=int, default=15, help='Specify the target length')
parser.add_argument('number', type=int, default=10, help='Specify the number of elements')
parser.add_argument('-v', '--version', action='version', version='%(prog)s 1.0') # version
args = parser.parse_args() #Interpret command line arguments
And the obtained value is
args.target
args.number
It seems that it can be taken out like.
Oh, convenient. It seems that you can specify it with various other options, but I don't need it now, so that's it.
end.
Recommended Posts