python获取参数的写法
2014-11-24 14:33
190 查看
import getopt
optargs = sys.argv[1:]
try:
opts, args = getopt.getopt(optargs, "f:b:r:", ["file=", "backdays=", "region="])
except getopt.GetoptError as err:
sys.stderr.write("[ERROR] Invalid Syntax\n")
sys.exit(1)
for opt, arg in opts:
if opt in ("-f", "--file"):
pnl_file = arg
elif opt in ("-b", "--backdays"):
backdays = int(arg)
elif opt in ("-r", "--region="):
region = arg
optargs = sys.argv[1:]
try:
opts, args = getopt.getopt(optargs, "f:b:r:", ["file=", "backdays=", "region="])
except getopt.GetoptError as err:
sys.stderr.write("[ERROR] Invalid Syntax\n")
sys.exit(1)
for opt, arg in opts:
if opt in ("-f", "--file"):
pnl_file = arg
elif opt in ("-b", "--backdays"):
backdays = int(arg)
elif opt in ("-r", "--region="):
region = arg
相关文章推荐
- Python 2.7.9 Demo - 获取调用的参数
- python 获取脚本传递参数 及参数个数 检查文件 变量 是否存在 退出脚本
- 在Python3.0中使用HTTPServer处理web请求2-获取请求参数
- python_9(获取字典值、函数参数、函数返回值、lambda的函数用法)
- python通过urllib2获取带有中文参数url内容的方法
- 在Python中调用shell命令及 获取python命令中的参数
- python web应用开发中获取各种参数的方式
- python通过urllib2获取带有中文参数url内容的方法
- 探寻main函数的标准写法,以及获取main函数的参数、返回值
- Flex获取url参数的一些写法
- Python脚本获取参数的方式
- 【好文要转】Python:模拟登录以获取新浪微博OAuth的code参数值
- Python使用Flask框架获取当前查询参数的方法
- python执行shell获取硬件参数写入mysql的方法
- python-如何获取命令行是参数
- python获取url地址中的参数
- 汇编 使用堆栈传参时 子程序获取参数的写法
- Javascript获取URL参数的简单写法
- python 使用getopt 获取配置参数
- flex获取url参数的一些写法