python_argparse
使用python argparser处理命令行参数
#coding:utf-8
# 导入模块
import argparse # 创建ArgumentParser()对象
parser = argparse.ArgumentParser() # 调用add_argument()方法添加参数
#添加定位参数
parser.add_argument("square", help="display a square of a given number", type=int)
#添加可选参数
parser.add_argument("--square", help="display a square of a given number", type=int)
parser.add_argument("--cubic", help="display a cubic of a given number", type=int) # 使用parse_args()解析添加的参数
args = parser.parse_args() print args.square
print args.cubic
python_argparse的更多相关文章
- python的os模块fnmatch模块介绍
一.先介绍一下os模块 import os print(os.getcwd()) # E:\python\test\python_models # 获取当前的目录 print(os.listdir(& ...
随机推荐
- mongoose基于mongodb的数据评论设计
var CommentSchema = { data:{type: ObjectId, ref:'Data'}, //Data数据表,此处存数据id from:{type: ObjectId, ref ...
- Struts status
#status.odd 是否奇数行 #status.count 当前行数 #status.index 当前行的序号,从0开始[#status.count=# ...
- 1022. Fib数列
https://acm.sjtu.edu.cn/OnlineJudge/problem/1022 Description 定义Fib数列:1,1,2,3,5,8,13,…1,1,2,3,5,8,13, ...
- React + webpack 环境配置
安装配置Babel babel-preset-es2015 ES6语法包,使代码可以随意地使用ES6的新特性. babel-preset-react React语法包,专门用于React的优化,在代码 ...
- bzoj4670: 佛罗里达
这题直接随机化+贪心就可以爆踩过去,我加了个退火增加容错率而已....其实你随机的次数够多根本不需要... 然后来自肉丝哥哥的正经做法: 先钦定D(A)>D(B),那么可以枚举D(A),然后再去 ...
- Linux系统中10个常用的ps命令总结
Linux作为Unix的衍生操作系统,Linux内建有查看当前进程的工具ps.这个工具能在命令行中使用PS 命令是什么 查看它的man手册可以看到,ps命令能够给出当前系统中进程的快照.它能捕获系统在 ...
- ansible 基础知识
英文官网,值得拥有! http://docs.ansible.com/ansible/list_of_files_modules.html# 摘自: http://blog.csdn.net/b624 ...
- 操作 AutoIT:界面与自动化操作结合来简化日常劳动: .Net Reactor验证License,设置License,创建License,截图AutoIt自动化实现。(六)
自动化操作的稳定性,便利性虽然已经满足了要求,但是页面上呈现的按钮太多了,可以做的更加简单一些. 1. 简化页面的按钮,把5个按钮减少至3个,把Display HID按钮功能整合到create lic ...
- CSS:CSS cursor 属性
ylbtech-CSS:CSS cursor 属性 1.返回顶部 1. 实例 一些不同的光标: span.crosshair {cursor:crosshair;} span.help {cursor ...
- Qt5.7不能加载MySql驱动问题.(需要重新编译驱动)
转自:http://blog.csdn.net/qq_28851503/article/details/52422302 首先贴上我遇到的问题,如下: QSqlDatabase: QMYSQL dri ...