UnicodeDecodeError in Python — What It Means and How to Fix It
What Python's UnicodeDecodeError exception means and how to resolve it.
Published October 28, 2026
UnicodeDecodeError is raised when bytes can't be decoded into text using the specified encoding.
Key points
- Catch it specifically with "except UnicodeDecodeError:" when you want to handle this exact case rather than a bare except
Example
b'\xff'.decode('utf-8') # UnicodeDecodeError