0

After running this simple program:

import os
#listo=[]
fin=open(os.path.expanduser("~/Downloads/Untitled.txt"))
for line in fin:
    print(line)

I get the error 'ascii' codec can't decode byte 0xe2 in position 59: ordinal not in range(128). A similar question here has solutions that seem to not work on Python 3.

I read that Python 3 uses utf-8 for encoding a txt file, then why is ascii used here? How can I solve this?

Thanks :)

Community
  • 1
  • 1
Ind Oubt
  • 151
  • 1
  • 8

0 Answers0