其他分享
首页 > 其他分享> > 查看文件夹中所有文件编码

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

作者:互联网

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))

标签:编码,查看,f1,filepath,filelist,filename,文件夹,filenames,data
来源: https://blog.csdn.net/weixin_50810323/article/details/122733789