+ 1
Q. Python Exception
except TypeError as e: print(e) Is it possible to do the same for except: So that i can get a brief description about the error.
2 odpowiedzi
+ 6
You can do it in a more general way, without naming each exception in detail:
number = '3'
try:
result = number + 10
except Exception as e:
print('Error:',e)
# output:
"Error: must be str, not int"
+ 4
No, you can't. With last example you just detect existence of an error, but dont actually get it