用chardet检测编码
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)
原文地址:https://www.cnblogs.com/Py00/p/8881850.html
时间: 2024-12-29 16:47:43