How to solve the problem of File Encoding in python Reading

stephen@ubuntu:~/qichacha$ python3 qichacha.py 
Traceback (most recent call last):
  File "qichacha.py", line 286, in <module>
    qichacha().read_data()
  File "qichacha.py", line 71, in read_data
    str = f.read()
  File "/usr/lib/python3.5/codecs.py", line 321, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: "utf-8" codec can"t decode byte 0xd0 in position 0: invalid continuation byte

clipboard.png

Mar.21,2021

it should be a mistake to save the content containing bom with txt.
method 1:
Open the web page, copy the content, and post it in the notepadPP that is set to utf-8.
method 2:

import codecs
str = f.read()
if str[:3] == codecs.BOM_UTF8:
    str = str[3:]

use the heart's str for operations

Menu