Having an issue while trying to open .txt file (which contains only pure text in it) with Python 3.6 using simple open ()
approach:
with open('3003.txt', 'r') as myfile:
data=myfile.read()
It gives the errortrace like that:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe0 in position 182: invalid continuation byte
I used couple of googled approaches but they dont solve the deal. What should be done to solve this?
You can use Python 3 open()
style file handler which streams bytestrings:
open('3003.txt', 'rb') as myfile:
data=myfile.read()
Note the 'b' meaning binary mode
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.