查看文件夹中所有文件编码

import chardet
filepath = r"D:\WX\WeChat Files\wxid_ufkabu0ilg7s21\FileStorage\File\2021-12\竞品10.14-11.23"
filelist=[]
for root, dirnames, filenames in os.walk(filepath):
for filename in filenames:
filelist.append(os.path.join(root,filename))

for i in filelist:
with open(i, ‘rb’) as f1:
data =f1.read()
print(chardet.detect(data))

上一篇:python数据类型


下一篇:斐波那契数列C语言