I want to open a txt file for processing, I get an error: utf-8 'codec can't decode byte 0xd0, everything is in Unicode, but there may be lines like this, how to make python not interpret them as bytes? maybe I don't understand something?
1 answer
with codecs.open(file_name, "r",encoding='utf-8', errors='ignore') as fdata: - I do not really understand how to work with this design - FFF3_ZE
- Do not use codecs. The author has the usual open () reads Unicode (which Python 3 indicates). You can specify an error handler there. Even on Python 2.7, io.open should be used instead of codecs.open in most cases. - jfs
|
print(open("text.txt", "rb").read())- jfs