Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try ... except... finally 问题! #4

Open
duck2b opened this issue Jun 21, 2018 · 1 comment
Open

try ... except... finally 问题! #4

duck2b opened this issue Jun 21, 2018 · 1 comment

Comments

@duck2b
Copy link

duck2b commented Jun 21, 2018

image

如图,还是会报NameError

@zhangshuw
Copy link

老师这个例子应该是有问题的,他想表达的应该是
try:
f1 = open('name.txt')
i = 1 / 0
except Exception as e:
print(e)
finally:
f1.close()

你遇上这个问题应该是和java关闭流一样,一般finally会进行一个判空再进行关闭

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants