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

posted @ 2021-09-27 09:49  小艾衰  阅读(314)  评论(0编辑  收藏  举报