I'm learning how to read text files. I used this way:
f=open("sample.txt")
print(f.read())
It worked fine if I typed the txt file myself. But when I copied text from a news article on the web, it produced the following error:
UnicodeEncodeError: 'charmap' codec can't encode charater '\u2014' in position 738: character maps to undefined
I tried changing the Encoding setting in Notepad++ to UTF-8 as I read somewhere it is due to that
I also tried using:
f=open("sample.txt",encoding='utf-8')
from here
But it still didn't work.