1. 程式人生 > >編碼encode,表現形式是轉換成 bytes,實際轉換成gbk或者utf-8

編碼encode,表現形式是轉換成 bytes,實際轉換成gbk或者utf-8

# s = 'alex'
# s1 = b'alex'
# print(s,type(s))
# print(s1,type(s1))

# s = '中國'
# print(s,type(s))
# s1 = b'中國'
# print(s1,type(s1))

s1 = 'alex'
# encode 編碼,如何將str --> bytes, ()
s11 = s1.encode('utf-8')
s11 = s1.encode('gbk')
print(s11)
s2 = '中國'
s22 = s2.encode('utf-8')
s22 = s2.encode('gbk')
print(s22)