Library argparse
in python could help user handle arguments passed through command prompt, below I record the most important functions :
Add argument
1 | import argparse |
Result
1 | C:\pytest>argparse-test.py -foo=bar |
Add –help
1 | import argparse |
Result
1 | C:\pytest>argparse-test.py -h |
Add default value
1 | import argparse |
Result
1 | C:\pytest>argparse-test.py |
Specify argument type
1 | import argparse |
Result
1 | C:\pytest>argparse-test.py |