UnicodeError
Built-in ExceptionPython 2.0+Intermediate
Base class for Unicode encoding/decoding errors
Quick Info
- Documentation
- Official Docs
- Python Version
- 2.0+
Learn by Difficulty
Quick Example
python
# Triggering and catching UnicodeError try: b"\xff".decode("ascii") except UnicodeError as e: print(f"Caught UnicodeError: {e}") print(f"Type: {type(e).__name__}")
UnicodeError is raised when base class for unicode encoding/decoding errors. Always catch specific exceptions rather than bare except clauses.
Try in PlaygroundTags
exceptionerror-handlingcore