Module introduced way:
import argparse
The description parameter may be used to describe the script information into use, can be null
parser = argparse.ArgumentParser(description="your script description")
--Verbose added label, the label may be an alias -v, where the action means that appears --verbose / -v when the read parameter when the parameter verbose built dictionary corresponding value is True, and parameter help describe use or meaning --verbose parameter.
parser.add_argument('--verbose', '-v', action='store_true', help='verbose mode')
Conversion parameters dictionary
args = parser.parse_args()
To ensure that some of the required input parameters, custom labels may require increasing requirement. For example, the following statement, wherein the required label --verbose That parameter is required, and int, and other types of input error.
parser.add_argument('--verbose', required=True, type=int)