Opened this issue 6 years ago · 1 comments
如图,还是会报NameError
老师这个例子应该是有问题的,他想表达的应该是 try: f1 = open('name.txt') i = 1 / 0 except Exception as e: print(e) finally: f1.close()
你遇上这个问题应该是和java关闭流一样,一般finally会进行一个判空再进行关闭