Python UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa1 in position 4: invalid start byte

报错代码:


报错内容:

Traceback (most recent call last):

  File "F:\python练习\303-1.py", line 5, in

    ls = f.readlines()

  File "C:\Users\111\AppData\Local\Programs\Python\Python310\lib\codecs.py", line 322, in decode

    (result, consumed) = self._buffer_decode(data, self.errors, final)

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa1 in position 4: invalid start byte

修改,删除第一行的encoding就ok了


你可能感兴趣的:(Python UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa1 in position 4: invalid start byte)