'''
码的类型:
ascii 英: 0000 0000 八位 ,一个字节
unicode 英:0000 0000-0000 0000-0000 0000-0000 0000 三十二位 ,四个字节
中:000 0000-0000 0000-0000 0000-0000 0000 三十二位 ,四个字节
utf-8 英:0000 0000-0000 0000-0000 0000 二十四位,三个字节
中:0000 0000-0000 0000-0000 0000 二十四位,三个字节
gbk 英:0000 0000 八位,一个字节
中:0000 0000-0000 0000 十六位,两个字节
。。。。。。。
python3 编码所用为Unicode,而文件储存,传输必须为Unicode以外类型(Unicode太大),所以需要进行转换
'''
#bytes类型,str.encode('byte')
str = '中国'
str0 = 'zhongguo'
e = str.encode('utf-8')
e0 = str0.encode('utf-8')
print(e,e0)
#英文,中文编码方式一样,但表现形式不一样;
# #b'\xe4\xb8\xad\xe5\x9b\xbd' b'zhongguo'
e = str.encode('gbk')
e0 = str0.encode('gbk')
print(e,e0)
#b'\xd6\xd0\xb9\xfa' b'zhongguo'