UnicodeDecodeError (character maps to ) when reading a text file [duplicate]

23 hours ago 5
ARTICLE AD BOX

UnicodeDecodeError means Python is reading the file with the wrong text encoding.

Your file likely is not being decoded correctly by the default Windows encoding, so specify one explicitly:

with open("0_intro.txt", "r", encoding="utf-8") as intro_doc: print(intro_doc.read())

If that still fails, try encoding="cp1252".

Also, intro_text.close is incorrect:

intro_text is a list, not the file

close needs parentheses

using with open(...) is better because it closes the file automatically

Read Entire Article