复制代码
1
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')
参数数量及类型错一个都不行,必修参数
最后
以上就是眯眯眼电源最近收集整理的关于argparse必选参数的全部内容,更多相关argparse必选参数内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复