import chardet raw = open("model.json", 'rb').read() result = chardet.detect(raw) # 检测编码 encoding = result['encoding'] f = open("model.json", "r", encoding=encoding) lines = f.readlines() for line in lines: print(line)