test.py
import argparse
parser = argparse.ArgumentParser(description='Example with non-optional arguments') parser.add_argument('count', action="store", type=int) parser.add_argument('units', action="store")
print(parser.parse_args())
python3 test.py 3 i
Namespace(count=3, units='i')
参数数量及类型错一个都不行,必修参数