#coding=utf-8
import sys,getopt
#读取命令行参数
opts,args = getopt.getopt(sys.argv[1:],"hc:",["help","config="])
#显示帮助信息
def usage():
print sys.argv[0]+' -c configFilePath'
print sys.argv[0]+' -config configFilePath'
print sys.argv[0]+' --help / -h'
#重置config参数
config=None
for op,value in opts:
if op == '-c' or op == '-config':
config = value
elif op == '--help' or op == '-h':
usage()
sys.exit()
if config:
print("read successful")
print op
print value
else:
print("read fail")
usage()
python 读取命令行参数
最新推荐文章于 2023-04-02 21:22:06 发布