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?
Asked
Active
Viewed 775 times
-1

Yılmaz Alpaslan
- 327
- 3
- 16
-
1`open(..., encoding='utf-8')`…? – deceze Jun 01 '21 at 08:51
1 Answers
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