python v2.7 has a module called argparse that makes it easy to set arguments. With this, you can easily create a python script, so I will post a template.
# coding:utf-8
import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='description')
parser.add_argument('arg1', type=int, help='integer argument')
parser.add_argument('arg2', type=str, help='string argument')
# -a or--True if all is specified,If not False is args.Stored in all
parser.add_argument('-a', '--all', action='store_true')
parser.add_argument('--seeds', nargs=2, type=int, help='int options')
args = parser.parse_args()
your_method(args.arg1, args.arg2)
One of the useful things about argparse is
Besides, it is possible to handle many arguments and bundle the arguments in a list, but for the time being, a brief explanation.
Recommended Posts