For Python 2.6 and later and Python 3.x:
except Exception as e: print(e)
For Python 2.5 and earlier, use:
except Exception,e: print str(e)
Related Contents:
- Why is “except: pass” a bad programming practice?
- Raise warning in Python without interrupting program
- Log exception with traceback in python
- “Inner exception” (with traceback) in Python?
- A safe max() function for empty lists
- cannot catch SQLAlchemy IntegrityError
- Handling all but one exception
- Print an error message without printing a traceback and close the program when a condition is not met
- I’m getting an IndentationError. How do I fix it?
- How can I safely create a nested directory?
- Catch multiple exceptions in one line (except block)
- How to properly ignore exceptions
- Which exception should I raise on bad/illegal argument combinations in Python?
- What is the intended use of the optional “else” clause of the “try” statement in Python?
- Why return NotImplemented instead of raising NotImplementedError
- How to retry after exception?
- live output from subprocess command
- django MultiValueDictKeyError error, how do I deal with it
- How do I catch a numpy warning like it’s an exception (not just for testing)?
- How to return 0 with divide by zero
- Is there a difference between “raise exception()” and “raise exception” without parenthesis?
- Generic catch for python
- How can I know which exceptions might be thrown from a method call?
- hasattr() vs try-except block to deal with non-existent attributes
- IndexError: too many indices for array
- Python: Catching specific exception
- Exception thrown in multiprocessing Pool not detected
- Get HTTP Error code from requests.exceptions.HTTPError
- Python Multiprocessing: Handling Child Errors in Parent
- Python exception handling – line number
- How to exit a program: sys.stderr.write() or print
- python selenium webscraping “NoSuchElementException” not recognized
- Can I catch error codes when using Fabric to run() calls in a remote shell?
- How do I log an exception at warning- or info-level with traceback using the python logging framework?
- check what files are open in Python
- Python global exception handling
- Python requests exception handling
- One try block with multiple excepts
- Printing out actual error message for ValueError
- threading ignores KeyboardInterrupt exception
- Converting Exception to a string in Python 3
- Making Python’s `assert` throw an exception that I choose
- python try:except:finally
- “outsourcing” exception-handling to a decorator [closed]
- Custom Python Exceptions with Error Codes and Error Messages
- How “with” is better than try/catch to open a file in Python?
- rethrowing python exception. Which to catch?
- Get key name from Python KeyError exception
- How to silence “sys.excepthook is missing” error?
- Break on exception in pydev