#384 自适应文件编码打开文件   python     snippets     编码     2 years ago (owner) Document
import chardet
# 首先二进制方式打开文件
with open(absPath, 'rb') as frb:
    # 检测编码方式
    cur_encoding = chardet.detect(frb.read())['encoding']
# 指定文件编码方式
with open(absPath, 'r', encoding=cur_encoding) as fr:
    Content = fr.read()