对于python的打包,有时候需要进行参数控制。下面是一个示例。
#启动命令:-r yes
def main(argv):
IsCanRun = False
try:
opts, args = getopt.getopt(argv, "hr:", ["Run="])
except getopt.GetoptError:
print('wrong')
sys.exit(2)
for opt, arg in opts:
if opt in ("-r", "--Run"):
strRun = arg
if strRun == 'yes':
IsCanRun = True
if False != IsCanRun:
Run()
else:
sys.exit()