-1

I want to read all contents inside a file and print them into console but print(open('file.txt',mode='r').read()) code outputs €â– instead of █, ▓, ░ characters and I don't want it. I need to print █, ▓, ░ characters. Is there a way to output all UTF-8 characters correctly?

Yılmaz Alpaslan
  • 327
  • 3
  • 16

1 Answers1

1

Try to put the encoding in your open-call like this ,encoding='utf-8' in your read(). This way to tell python which encoding is used for the file.

In the end you would have something like this print(open('file.txt',mode='r', encoding='utf-8').read())

8ball
  • 138
  • 1
  • 9