argparser 的bool 参数 无法传入的问题

设置为bool参数时 无法传送参数
使用 action='store_true'

store_true 是指带触发action时为true,不触发则为false, store_false则相反

parser.add_argument("--trained", action='store_true', help="whether load trained model")
使用方法:
python main.py --trained 触发 参数为true
python main.py 不触发 参数为false

原文地址:https://www.cnblogs.com/ashyLoveLoli/p/15341573.html