# coding=UTF-8
# see: https://www.cnblogs.com/victorwu/p/5762665.html
# python2.7 可用
import argparse
parser = argparse.ArgumentParser(description = '支持的命令描述信息')
parser.add_argument('--ver', '-v', help = '测试的参数')
parser.add_argument('-p','--port', type=int, help='制动端口参数')
# 将变量以标签-值的字典形式存入args字典
args = parser.parse_args()
if args.ver:
print args.ver
if args.port:
print args.port
转载于:https://www.cnblogs.com/jzsg/p/10926509.html