I am trying to read some information from some .txt
files, they are all in english and they do not have any other unicode character, the problem is that for an especific file it just crashed and do not show the information, the error is
Traceback (most recent call last):
File "C:\users\bienvenido\desktop\programmacion\harvard\cs50 artificial inteligence\6\questions\questions.py", line 107, in <module>
main()
File "C:\users\bienvenido\desktop\programmacion\harvard\cs50 artificial inteligence\6\questions\questions.py", line 16, in main
files = load_files(sys.argv[1])
File "C:\users\bienvenido\desktop\programmacion\harvard\cs50 artificial inteligence\6\questions\questions.py", line 59, in load_files
files[file] = f.read()
File "C:\Users\BIENVENIDO\AppData\Local\Programs\Python\Python39\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 38619: character maps to <undefined>
and what i am doing is
with open(os.path.join(directory,file), encoding='utf-8') as f:
files[file] = f.read()
print(files[file])
I also tried utf16
and default
encoding