我的程序中有以下几行
parser = OptionParser()
parser.add_option("-t","--TIMEOUT", dest="timeout", type="int", help="timeout in seconds")
if parser.has_option("-t") and options.timeout<=0:
print "Timeout if specified must be greater than zero"
sys.exit(CLI_ERROR)
上面的打印语句正在打印,因为即使没有为此脚本指定 -t 选项, parser.has_option("-t") 的评估结果也为 true。我在这里错过了什么吗?在此先感谢您的帮助。