0 votes
1 view
in Python by (1.6k points)

try:

    something here

except:

    print 'the whatever error occurred.'

How can I print the error/exception in my except: block?

2 Answers

0 votes
by (25.1k points)

You can print an exception like this:

try:

    something here

except Exception as e:

    print(e)

0 votes
by (107k points)

To print an exception in Python you can use below-mentioned code:-

except Exception as e: 

print(e)

Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...