Python Exception draft

Last modified 4 years ago / Edit on Github
Danger icon
The last modifications of this post were around 4 years ago, some information may be outdated!
Danger icon
This is a draft, the content is not complete and of poor quality!

Try..Except

try:
# codes
except:
# codes run if there is an exception
try:
# codes
except:
# codes run if there is an exception
else:
# no exception?
try:
# try codes
except FileNotFoundError as fnf_error:
print(fnf_error)
except AssertionError as error:
print(error)

Other Errors, check this list.

Apply

Check str of float

element = 'mean'
try:
print(float(element))
except ValueError:
if element == 'mean':
print('hello mean')

💬 Comments

Support Thi Support Thi