python parser.parse_args action=‘store_true‘ 和 ‘store_false’

store_true就是存储的值为true(store_false 就是存储的值为false),
用sh 命令触发值的设置:

parser.add_argument('-p', action='store_true', default=false)
#python test.py -p          => p 是true(触发设置)
#python test.py             => p 是false(无触发,default优先赋值)
 

 

posted @   海_纳百川  阅读(58)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
· 【杂谈】分布式事务——高大上的无用知识?
本站总访问量8989356
 
点击右上角即可分享
微信分享提示