help! 研究两天了,utf-8,gbk,gb10啥的网上能试一试的代码都试过了,打开的文件就是普通的记事本文件里面几个字,问题到底出在哪里,快崩溃了

源代码:
with open('班级任职.txt','r',encoding='utf-8')as f:
    a=f.read()
    print(a)

报错
Traceback (most recent call last):
  File "C:\Users\安\Desktop\123.py", line 2, in 
    a=f.read()
  File "C:\Users\安\AppData\Local\Programs\Python\Python39\lib\codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xaa in position 14: invalid start byte



干脆别加 encoding='utf-8' 试试,应该问题不大呀

我之前有的网上下载的txt会乱码,你的这个txt是自己输入的吗。

你另存为一下这个文件,看看它的编码格式是啥

img

谢谢大家的帮助,我问了我的老师,老师说不能直接打开,因为excel是编码文件要用xlrd和pandas打开,直接with open是不可以的