The following error occurred while reading the ".jpg" file:
UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 334: character maps to <
Function where reading is performed:
def readFile (self, data_path): if self.mode== 'encode': input_file= open (data_path, 'r') data= input_file.read () else: pass input_file.close () return data
Answer # 1
.jpgthe file needs to be read in binary mode:
with open (data_path, 'rb') as input_file: ^^^^ binary mode data= input_file.read ()
But in general, you do not understand what will happen with another
mode, the code will break completely then.
- Python does not see pip3 modules
- python : Determine the length of the longest string consisting of only characters A, B and C
- python : Find k numbers closest to a given value in an ordered array
- python : how can one split each word in a two dimensional array into separate characters
- python : The code works, but the execution time limit is exceeded
- How to count the number of specific letters in a word generated by a loop -Python
- python : How to validate user input in a telegram bot?
- python : How can I find the words that are given in the second array in the first array
- python : Why do we need Dekstop PyQt5 window type?