In binary, 0xE9 looks like 1110 1001
. If you read about UTF-8 on Wikipedia, you’ll see that such a byte must be followed by two of the form 10xx xxxx
. So, for example:
>>> b'\xe9\x80\x80'.decode('utf-8') u'\u9000'
But that’s just the mechanical cause of the exception. In this case, you have a string that is almost certainly encoded in latin 1. You can see how UTF-8 and latin 1 look different:
>>> u'\xe9'.encode('utf-8') b'\xc3\xa9' >>> u'\xe9'.encode('latin-1') b'\xe9'
(Note, I’m using a mix of Python 2 and 3 representation here. The input is valid in any version of Python, but your Python interpreter is unlikely to actually show both unicode and byte strings in this way.)
Related Posts:
- How to resolve TypeError: can only concatenate str (not “int”) to str [duplicate]
- How to correct TypeError: Unicode-objects must be encoded before hashing?
- How do you decode Base64 data in Python?
- How to remove \xa0 from string in Python?
- What does the ‘b’ character do in front of a string literal?
- What does the ‘b’ character do in front of a string literal?
- (unicode error) ‘unicodeescape’ codec can’t decode bytes in position 2-3: truncated \UXXXXXXXX escape
- (unicode error) ‘unicodeescape’ codec can’t decode bytes in position 2-3: truncated \UXXXXXXXX escape
- “Unicode Error “unicodeescape” codec can’t decode bytes… Cannot open text files in Python 3
- Python – ‘ascii’ codec can’t decode byte
- UnicodeEncodeError: ‘ascii’ codec can’t encode character u’\xa0′ in position 20: ordinal not in range(128)
- Python string prints as [u’String’]
- NameError: global name ‘unicode’ is not defined – in Python 3
- Convert a Unicode string to a string in Python (containing extra symbols)python string unicode type-conversion
- Using unicode character u201c
- What is a unicode string?
- Convert Unicode to ASCII without errors in Python
- TypeError: coercing to Unicode: need string or buffer, int found
- What exactly do “u” and “r” string flags do, and what are raw string literals?
- How to write unicode strings into a file?
- numpy max vs amax vs maximum
- TypeError: ‘str’ object is not callable (Python)
- ValueError: invalid literal for int() with base 10: ”
- Print string to text file
- How can I parse a YAML file in Python
- Cannot find module cv2 when using OpenCV
- Maximum and Minimum values for ints
- How is Anaconda related to Python?
- What is the python keyword “with” used for? [duplicate]
- What is the purpose of meshgrid in Python / NumPy?
- Proper way to declare custom exceptions in modern Python?
- TypeError: ‘float’ object not iterable
- write() versus writelines() and concatenated strings
- Why is it string.join(list) instead of list.join(string)?
- Importing class from another file [duplicate]
- Pandas group-by and sum
- Python List vs. Array – when to use?
- How to terminate a script?
- numpy array concatenate: “ValueError: all the input arrays must have same number of dimensions”
- csv.Error: iterator should return strings, not bytes
- SyntaxError: non-default argument follows default argument
- socket.error: [Errno 48] Address already in use
- Creating a basic auto clicker in python
- Pandas ‘count(distinct)’ equivalent
- How can I flush the output of the print function?
- Python calling method in class
- No module named pkg_resources
- Opening a .ipynb.txt File
- How do I remove all packages installed by PIP?
- ValueError: need more than 1 value to unpack python
- What is the best way to exit a function (which has no return value) in python before the function ends (e.g. a check fails)?
- How to disable Python warnings?
- LinAlgError: Last 2 dimensions of the array must be square
- How to get data from SNMP with python?
- What does axis in pandas mean?
- How can I download Anaconda for python 3.6
- django:django.core.exceptions.AppRegistryNotReady: Apps aren’t loaded yet
- Replace and overwrite instead of appending
- module ‘pandas’ has no attribute ‘rolling_mean’
- Displaying better error message than “No JSON object could be decoded”
- List attributes of an object [duplicate]
- How can I set the aspect ratio in matplotlib?
- In Python how should I test if a variable is None, True or False
- Pythonic way to iterate through a range starting at 1
- Convert from CSV to array in Python
- Type error Unhashable type:set
- Saving a Numpy array as an image
- TypeError: ‘bool’ object is not callable
- How do I maximize the display screen in PyGame?
- Why does PyQt crashes without information? (exit code 0xC0000409)
- “for loop” with two variables?
- How to put the legend out of the plot
- How can I check the extension of a file?
- Matplotlib: TypeError: can’t multiply sequence by non-int of type ‘numpy.float64’
- Create nice column output in python
- TypeError: unsupported operand type(s) for +=: ‘int’ and ‘list’
- TypeError: int() argument must be a string, a bytes-like object or a number, not ‘list’
- What is the difference between a string and a byte string?
- “This constructor takes no arguments” error in __init__
- plot a circle with pyplot
- TypeError: super() takes at least 1 argument (0 given) error is specific to any python version?
- ValueError: cannot switch from manual field specification to automatic field numbering
- TemplateDoesNotExist at /
- How do I update a Python package?
- How to create Gephi network graphs from Python?
- strncmp in python
- How can I count time in Python 3?
- how to build .exe for python 3.5+, 3.6 if possible?
- How to query as GROUP BY in django?
- Python regex match space only
- OpenCV houghLinesP parameters
- Generate a random letter in Python
- NameError from Python input() function
- How do I tell Matplotlib to create a second (new) plot, then later plot on the old one?
- Python how to write to a binary file?
- How to download a file via FTP with Python ftplib
- How do I restart a program based on user input?
- Python Pandas : pivot table with aggfunc = count unique distinct
- Flask Value error view function did not return a response [duplicate]
- AttributeError: ‘Series’ object has no attribute ‘split’ error in sending emails