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)
More Related Contents:
- I’m getting an IndentationError. How do I fix it?
- Why is “except: pass” a bad programming practice?
- How do I print an exception in Python?
- “Inner exception” (with traceback) in Python?
- Log exception with traceback in Python
- Print an error message without printing a traceback and close the program when a condition is not met
- How can I safely create a nested directory?
- Catch multiple exceptions in one line (except block)
- How to properly ignore exceptions
- How do I check if a variable exists?
- Proper way to declare custom exceptions in modern Python?
- What is the intended use of the optional “else” clause of the “try” statement in Python?
- Should I always specify an exception type in `except` statements?
- selenium.common.exceptions.InvalidSelectorException with “span:contains(‘string’)”
- Failed to catch syntax error python [duplicate]
- Python exception chaining [duplicate]
- Importing installed package from script with the same name raises “AttributeError: module has no attribute” or “ImportError: cannot import name”
- In Python, how does one catch warnings as if they were exceptions?
- How to solve “OSError: telling position disabled by next() call”
- How can I know which exceptions might be thrown from a method call?
- Python: Getting a traceback from a multiprocessing.Process
- Don’t show Python raise-line in the exception stack
- Python: How to ignore an exception and proceed? [duplicate]
- How can I safely create a directory (possibly including intermediate directories)?
- How do I raise the same Exception with a custom message in Python?
- Error handling in Python-MySQL
- Default value in Python unpacking
- Adding information to an exception? [duplicate]
- How to return a custom 404 Not Found page using FastAPI?
- Multiple try codes in one block