更新时间:2023-02-20 10:56:04
chardet.detect
返回一个字典,键'encoding'
。所以你可以这样做:
chardet.detect
returns a dictionary which provides the encoding as the value associated with the key 'encoding'
. So you can do this:
import chardet
rawdata = open(infile, "r").read()
result = chardet.detect(rawdata)
charenc = result['encoding']