+ 1
What if I will close the file without "try" and "finally" statements?
4 Antworten
+ 2
nothing happens my friend... it is just precaution. supposing you don't do anything weird on it you don't need to use finally and try
0
"Try"..."Finally" is a good way to handle possible exceptions.
0
if an exception happens and say is handled higher up, the finally clause ensures the code runs regardless.
basic example of how finally works:
def foo():
try:
return 0
finally:
return -1
0
But WHY?U CAN SIMPLY USE WITH ...AS MODEL