Python - 发生异常时的"if"语句

sit*_*lia -1 python if-statement exception

一旦异常消失,我想要一个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()
Run Code Online (Sandbox Code Playgroud)

dm0*_*514 6

您不应该需要条件,因为如果您在except块中,则表示发生了异常