python3的字符集测试
s_test=u"严"
print(s_test.encode('gbk'))
print([s_test])
#print(s_test[])
#print(unicode((s_test))
print('type',type('严'))
print('type','严')
print('gbk')
print(s_test.encode('gbk').decode('gbk'))
print(s_test.encode())
print('gbk')
print(s_test.encode('utf-8'))
print(s_test.encode('utf-8').decode('utf-8'))
print('unicode')
print(s_test.encode('unicode-escape'))
print(s_test.encode('unicode-escape').decode('unicode-escape'))
print('gb2312')
print(s_test.encode('gb2312'))
print(s_test.encode('gb2312').decode("gb2312"))
运行结果
b'xd1xcf'
['严']
type <class 'str'>
type 严
gbk
严
b'xe4xb8xa5'
gbk
b'xe4xb8xa5'
严
unicode
b'\u4e25'
严
gb2312
b'xd1xcf'
严