1 f = open(‘C:/Users/Administrator/Desktop/100.txt‘, ‘rb‘) 2 data = f.read() 3 # print(data) 4 f.close() 5 6 import chardet 7 print(chardet.detect(data)) 8 print(data.decode(‘ascii‘)) 9 10 {‘encoding‘: ‘ascii‘, ‘confidence‘: 1.0, ‘language‘: ‘‘} 11 需要先安装 12 pip install chardet