else and finally in try except
def func1():
with open("shiva.txt") as f:
print(f.read())
try:
with open("raj.txt") as f1:
print(f1.read())
# except will run when try will not satisfy")
#except Exception as e:
#print(e)
except IOError as e:
print("IO error hai bhai",e)
except EOFError as e:
print(e)
#else will run when except will not run")
else:
print("this will print when except will not run")
#anyway finally will run
finally:
print("anyway this will run")
f.close()
func1()
Comments
Post a Comment