如果我要使用以下代码:
try:
execfile("script.py")
except ## unsure what exception goes here...
continue:
try:
execfile("other.py")
except ## unsure what exception goes here...
continue:
如何捕获script.py中的所有错误,将其保存到文件中,然后继续执行下一个调用的脚本
任何人有任何想法或线索吗?
最佳答案
errors = open('errors.txt', 'w')
try:
execfile("script.py")
except Exception as e:
errors.write(e)
try:
execfile("other.py")
except Exception as e:
errors.write(e)
errors.close()
关于python - 在脚本中执行脚本,但继续进行错误并将其保存到文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18198574/