利用chardet包,查看文件编码格式
import chardet
fileName = 'XXXXX '
currentFile = open(fileName,mode='rb')
content = currentFile.read()
print(chardet.detect(content))
本文介绍如何利用Python的chardet包检测文件的编码格式。通过打开文件并读取其内容,然后使用chardet.detect()方法,可以准确地识别文件的编码类型。
利用chardet包,查看文件编码格式
import chardet
fileName = 'XXXXX '
currentFile = open(fileName,mode='rb')
content = currentFile.read()
print(chardet.detect(content))

被折叠的 条评论
为什么被折叠?