I work on a program in python which analyze files and keep only what I want in these files. I have an error when I open some files. These files contains string and bytes like that :
file.py:
if byte == "0xFD":
for byte in bytes.split["0xFD"]:
...
When I open that type of files, the strings present between quotes are interpreted as bytes and that makes the program crashed :
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 59752: character maps to <undefined>
. Same error with 'utf-8'.
So my question is: how can I read that line without interpreted the byte (I want to keep the line like that)?