lines = [line.rstrip() for line in open(r"C:UsersmagshimimPycharmProjectsasaf_avitalwords.txt")]
for line in lines:
if len(line) == 9 & line.index(" ") == 3:
print(line)
I tried to put all lines in the file to a list.
here is the erorr:
Traceback (most recent call last):
File "C:/Users/magshimim/PycharmProjects/asaf_avital/atav.py", line 2, in <module>
lines = [line.rstrip() for line in open(r"C:UsersmagshimimPycharmProjectsasaf_avitalwords.txt")]
File "C:/Users/magshimim/PycharmProjects/asaf_avital/atav.py", line 2, in <listcomp>
lines = [line.rstrip() for line in open(r"C:UsersmagshimimPycharmProjectsasaf_avitalwords.txt")]
File "C:Python38libencodingscp1255.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 1: character maps to <undefined>
question from:
https://stackoverflow.com/questions/65903517/why-cant-i-read-this-file-in-python 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…