下面是我的代码,我没有得到输出。。。在用inputfile和output file运行脚本之后。。。
def parseCommandLine(argv=[]):
inputfile = ''
outputfile = ''
FCSNAME = ''
try:
opts, args = getopt.getopt(
argv,
"hiop",
[help,"ifile=","ofile=","pcsfile="])
except getopt.GetoptError,msg:
printUsage()
print "-E-Badly formed command line vishal!"
print " ",msg
sys.exit(1)
#Processing command line arguments
for opt, arg in opts:
opt= opt.lower()
# Help
if opt in ("-h", "--help"):
printUsage()
sys.exit()
elif opt in ("-i", "--ifile"):
inputfile = arg
elif opt in ("-o", "--ofile"):
outputfile = arg
elif opt in ("-p", "--pcsname"):
PCSNAME = arg
if opt in ("-v"):
VERBOSE = 1
print 'Input file is "', inputfile
print 'Output file is "', outputfile
print 'PCS NAME is "', FCSNAME
# Verbose
return 0
输出: ./aaa_scr-i列表-o vishal
输入文件是“ 输出文件为“ FCS名称为“
没有输出。。请帮忙。
从}个元素。i、 e.程序名。在
sys.argv
中排除第{还有一些选项需要参数,因此需要使用
:
(冒号)来处理这些选项我希望这有帮助。在
第0个元素系统argvlist是getopt不喜欢的程序名。所以只需移除它,然后将argv传递给getopt。在
相关问题 更多 >
编程相关推荐