当前位置:网站首页>parser = argparse.ArgumentParser()解析
parser = argparse.ArgumentParser()解析
2022-08-02 03:21:00 【woshicaiji12138】
argument模块主要用于用户编写命令行接口;程序定义它需要的参数,然后argument从sys.argv中解析参数。
一、使用流程
1创建解析器
parser = argparse.ArgumentParser()
2参数设置
parser.add_argument(name or flags...[, action][, nargs][, const][, default][, type][, choices][, required][, help][, metavar][, dest])
name or flags:名字或者列表。
action:当参数在命令行中出现时使用的动作。
nargs:应该读取的命令行参数个数
const:不指定参数时的默认值
default:路径
type:类型
choices:参数可允许的值的另一个容器
required:可选参数是否可省略
help:参数的帮助信息
3解析参数
opt = parser.parse_args()
边栏推荐
- (转帖)HashCode总结(1)
- 活体检测 Adaptive Normalized Representation Learning for GeneralizableFace Anti-Spoofing 阅读笔记
- 自定义mvc框架复习(crud)
- Using WebShell to get Shell Skills
- 线性代数学习笔记3-1:矩阵与线性变换、常见矩阵(逆矩阵、伴随矩阵、正交矩阵等)
- (Reposted) The relationship between hashcode and equals
- [详解C语言]一文带你玩转C语言小游戏---三子棋
- oracle内连接和外连接
- 构造方法、方法重载、全局变量与局部变量
- mysql中如何查看表是否被锁
猜你喜欢
随机推荐
线性代数学习笔记2-2:向量空间、子空间、最大无关组、基、秩与空间维数
Monaco Editor 的基本用法
LeetCode:第304场周赛【总结】
mysql创建表
DSPE-PEG-PDP,DSPE-PEG-OPSS,磷脂-聚乙二醇-巯基吡啶供应,MW:5000
磷脂-聚乙二醇-巯基,DSPE-PEG-Thiol,DSPE-PEG-SH,MW:5000
2022.7.30 js notes Operators and flow controllers, loops
源码构建LAMP环境-1
MySQL8.0与MySQL5.7差异分析
线性代数学习笔记1:何为线性代数
(转帖)hashcode和equals的关系
debian 10 nat 与路由转发
删库后!除了跑路还能干什么?
HCIP-第十一天-MPLS+BGP
@Autowired详解[email protected]在static属性上的使用
第七周复习
MySQL占用CPU过高,排查原因及解决的多种方式法
@ApiModel 和 @ApiModelProperty
Day34 LeetCode
Daily practice------There are n integers, so that the previous numbers are moved back m positions in order, and the last m numbers become the first m numbers


![CV-Model [4]: MobileNet v3](/img/a1/fc3901d55b28aa080235f093b94cb4.png)






