【发布时间】:2015-05-17 21:07:01
【问题描述】:
我希望在异常发生后执行 if 语句。它的功能是什么,甚至有可能吗?
这就是我想要得到的
try:
save_this_number_file(s)
except:
print("could not find file. Don't forget to add *.txt* to the end of file name.")
if (except):
again = input("Would you like to try again? (y/n) ")
if (again != 'y'):
sys.exit()
【问题讨论】:
-
如果您在 except 块中,则异常已经发生。这不是充分条件吗?
标签: python exception if-statement