try, except, else e finally + Built-in Exceptions
This commit is contained in:
17
aula94.py
Normal file
17
aula94.py
Normal file
@@ -0,0 +1,17 @@
|
||||
# try, except, else e finally
|
||||
# https://docs.python.org/pt-br/3/library/exceptions.html#built-in-exceptions
|
||||
try:
|
||||
print('ABRIR ARQUIVO')
|
||||
8/0
|
||||
except ZeroDivisionError as e:
|
||||
print(e.__class__.__name__)
|
||||
print(e)
|
||||
print('DIVIDIU ZERO')
|
||||
except IndexError as error:
|
||||
print('IndexError')
|
||||
except (NameError, ImportError):
|
||||
print('NameError, ImportError')
|
||||
else:
|
||||
print('Não deu erro')
|
||||
finally:
|
||||
print('FECHAR ARQUIVO')
|
||||
Reference in New Issue
Block a user