【发布时间】:2014-07-21 03:17:09
【问题描述】:
我正在从另一个 python 文件运行 python 脚本。有没有办法知道第二个脚本中是否发生了错误?
EX: script1.py 调用 script2.py 蟒蛇脚本2。 py -参数 script1如何知道script2是否发生异常?
运行.py
import subprocess
subprocess.call("python test.py -t hi", shell=True)
test.py
import argparse
print "testing exception"
parser = argparse.ArgumentParser(description='parser')
parser.add_argument('-t', "--test")
args = parser.parse_args()
print args.test
raise Exception("this is an exception")
谢谢
【问题讨论】: