How to use argsparse to accept no flag and flag arguments
Question:
I want to do something like this
Case1: script.py –a="a_val" –b="b_val"
Both values are required for case 1
Case2: script.py –verify
Just need the –verify without any value
Answers:
Refer: https://docs.python.org/3/library/argparse.html
parser.add_argument('--verify', action='store_true')
I want to do something like this
Case1: script.py –a="a_val" –b="b_val"
Both values are required for case 1
Case2: script.py –verify
Just need the –verify without any value
Refer: https://docs.python.org/3/library/argparse.html
parser.add_argument('--verify', action='store_true')