Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from __future__ import print_function #Compatibilidade func print python 2/3
- #Handling exceptions and cleanup code in python
- #try...except...finally
- try:
- a = 1; b = 0;
- c = a/b;
- except Exception as ErrMsg:
- print ('ErrMsg:', ErrMsg)
- finally:
- print ('Always do it 1')
- #try...finally
- try:
- a = 1; b = 0;
- #c = a/b;
- finally:
- print ('Always do it 3')
- #try...except
- try:
- a = 1; b = 0;
- c = a/b;
- except:
- print ('Ocorreu um erro generico!')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement