Built-in Exceptions
UnicodeEncodeError — exception class
Text cannot be represented by the requested encoding under the chosen error policy. Inspect encoding, object and the failed character span. Use the correct encoding or an explicitly justified error policy rather than silently dropping data. Catch UnicodeEncodeError when this category is the recovery boundary; do not rely on the exact human-readable message.
Formal Syntax & Structure
python syntaxpython
UnicodeEncodeErrorReturn Value
type
The class object UnicodeEncodeError; this reference documents the class identity, not a universal constructor signature.
Working Example
Example Snippetpython
try: "é".encode("ascii")except UnicodeEncodeError as error: print(type(error).__name__)