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