手机
当前位置:查字典教程网 >脚本专栏 >python >python getopt 参数处理小示例
python getopt 参数处理小示例
摘要:opts,args=getopt.getopt(sys.argv[1:],"t:s:h",["walletype=","servicenam...

opts, args = getopt.getopt(sys.argv[1:], "t:s:h", ["walletype=", "servicename=",'help'])

for a,o in opts:

if a in ('-t', '--walletype'):

walle_type = o

elif a in ('-s', '--servicename'):

service_name = o

elif a in ('-h', '--help'):

help = True

其中t:s:h表示参数的缩写,:表示参数后需要传值

walletype=,servicename=,help表示参数的全称,=表示后面需要传值

【python getopt 参数处理小示例】相关文章:

python self,cls,decorator的理解

Python写的Socks5协议代理服务器

Python enumerate遍历数组示例应用

python中 ? : 三元表达式的使用介绍

使用cx_freeze把python打包exe示例

Python 时间处理datetime实例

Python urlopen 使用小示例

python批量修改文件后缀示例代码分享

python 获取本机ip地址的两个方法

python时间整形转标准格式的示例分享

精品推荐
分类导航