【发布时间】:2016-09-14 12:54:40
【问题描述】:
我有运行多个 python 和 shell 程序的 python 脚本 (installer.py):
print "Going to run Script1"
os.system("python script1.py")
print "Going to run Script2"
os.system("python script2.py")
但我发现即使 script1.py 因为错误而没有运行,它也会继续运行 script2.py。
如何在script1.py本身的时候停止脚本(installer.py)..
【问题讨论】:
-
你为什么要通过 os.system 出壳,而不是直接导入脚本?
-
您可能想通过
try和except了解错误处理。