I was trying to find a way to do this in python 3.6.5 which is not supported
try:
c=1/0
print (c)
except ZeroDivisionError, args:
print('error dividing by zero', args)
It says this type of syntax is not supported by python 3.6.5 So is there a way to get the arguments of the exception?
How about:
try:
c=1/0
print (c)
except ZeroDivisionError as e:
print('error dividing by zero: ' + str(e.args))
Comma notation is now used to except
multiple types of exceptions, and they need to be in parentheses, like:
try:
c = int("hello")
c = 1 / 0
print(c)
except (ZeroDivisionError, ValueError) as e:
print('error: ' + str(e.args))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With