File size: 207 Bytes
d1b91e7
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
import chardet


def get_encoding(file):
    with open(file, 'rb') as f:
        encoding = chardet.detect(f.read())['encoding']
    if encoding == 'GB2312':
        encoding = 'GB18030'
    return encoding