Reproduced in: error Unicode decodeerror during program operation: ‘UTF-8’ codec can’t decode byte 0x89 in position 0: invalid start byte
According to the solutions of others on the Internet, it is judged that there is a problem with the code entered in the file
For example:
It is solved by adding encoding = “unicode_escape” in the line of code reading the file, but it is useless to my program.
My one line code with file reading is
fh = open('data/example.png', 'r')
Find the previous Python notes. I think the syntax of reading the file is wrong. Change this line to
fh = open('data/example.png', 'rb')
Similar Posts:
- UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position 0-1:
- [Solved] Python Numpy Data load error: Unicode error: unpicking a python object failed: Unicode decodeerror
- [Solved] UnicodeDecodeError: ‘gbk’ codec can’t decode byte 0xa6 in position 9737: ill
- Python Open File SyntaxError: (unicode error) ‘unicodeescape’ codec can’t decode bytes in …
- [Solved] Yaml Text Error: UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte : illegal multibyte sequence
- The difference between UTF-8 and utf-8-sig
- Python Files Error: SyntaxError: (unicode error) ‘unicodeescape’ codec can’t decode bytes in position 2-3: tr
- [Solved] ‘utf-8’ codec can’t decode byte 0xd4 in position 1,invalid continuation byte
- [Solved] Pandas Parses MovieLens 1M Dataset Error: UnicodeDecodeError
- Python:SyntaxError: (unicode error) ‘unicodeescape’ codec can’t decode bytes in pos…