Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
for line in new:
#1
Hello,
I try to write program who will find the word in the file.

new=open(r'C:\Users\andrz\Desktop\New folder (3)\New.docx')
for line in new:
    line=line.rstrip()
    if not 'But' in line:
        continue
    print(line)
I have this Error:
Traceback (most recent call last):
File "C:/Users/andrz/PycharmProjects/selenium/New.py", line 3, in <module>
for line in new:
File "C:\Users\andrz\AppData\Local\Programs\Python\Python38-32\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 0x81 in position 637: character maps to <undefined>

What should I do?
Reply


Messages In This Thread
for line in new: - by andrzej357 - Jul-24-2020, 08:30 AM
RE: for line in new: - by ibreeden - Jul-24-2020, 08:43 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020