Argparse中action的可选参数store_true,store_false到底是什么意思?

store_true 是指触发action时为真,不触发则为假。

parser.add_argument('-c', action='store_true')#store_true表示出现-c时,要执行-c操作
python test.py -c         => c是true(触发)
python test.py            => c是false(无触发)
发布了50 篇原创文章 · 获赞 44 · 访问量 8896

猜你喜欢

转载自blog.csdn.net/tailonh/article/details/105369776