import chardet

s = b'\xd7\xaa\xd5\xbdOTT TV\xb1\xa6\xbd\xe0\xc7\xa3\xca\xd6\xd2\xf8\xba\xd3\xa1\xa4\xc6\xe6\xd2\xec\xb9\xfb'
print chardet.detect(s)
print s.decode('GB2312')
str = b'\xe5\xae\x9d\xe9\xb8\xa1\xe5\xb8\x82'
print(str.decode('utf-8'))
#result = chardet.detect(s) #if result: # encode = result['encoding'] # if encode: # print a.decode(encode)  输出 # {'confidence': 0.99, 'language': 'Chinese', 'encoding': 'GB2312'} # 转战OTT TV宝洁牵手银河・奇异果
05-23 13:53