python中的getopt模块
2015-07-31 18:53
531 查看
在日常的工作中免不了需要编写很多python脚本,当脚本的功能比较多的时候,又或者需要外部传入参数的时候,如果以参数
名和参数值的方式执行可能脚本显得更直观,也给自己提供方便。
python下有一个getopt的模块,该模块就是处理命令行参数的。
函数getopt(args,shortopts,longopts = [])
args一般是sys.argv[1:]
shortopys 短格式(-)
longopts 长格式(–) //两个杠
执行方法:
python run_cmd.py -f iplist.txt -c ifconfig
python run_cmd.py –file iplist.txt –command ifconfig
代码如下:
本文固定链接: http://www.wpython.com/433.html 转载请注明:
Ted 2014年07月28日 于
小强的博客 发表
名和参数值的方式执行可能脚本显得更直观,也给自己提供方便。
python下有一个getopt的模块,该模块就是处理命令行参数的。
函数getopt(args,shortopts,longopts = [])
args一般是sys.argv[1:]
shortopys 短格式(-)
longopts 长格式(–) //两个杠
执行方法:
python run_cmd.py -f iplist.txt -c ifconfig
python run_cmd.py –file iplist.txt –command ifconfig
代码如下:
本文固定链接: http://www.wpython.com/433.html 转载请注明:
Ted 2014年07月28日 于
小强的博客 发表
相关文章推荐
- python 的使用:getattr,hasattr
- python_getopt解析命令行输入参数的使用
- Python实现Table To Point代码
- Python实现Table To Point代码 分类: Python 2015-07-31 18:45 3人阅读 评论(0) 收藏
- python 之 分割参数getopt
- python2在pycharm中的中文乱码问题处理方式
- python3.x中的urllib模块
- Python实现fibnacci
- Python初步
- Python调用windows下DLL详解 - ctypes库的使用
- python 函数式编程
- Python GUI编程各种实现的对比
- python Iterable和Iterator
- Python中的局部变量和全局变量
- python range()函数
- python实现爬图,不要再爬妹子图了,太没品
- python的range()函数用法
- spark 集群运行python作业
- python 生成器
- python初学小结4