编码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)

猜你喜欢

转载自www.cnblogs.com/hopelv/p/10074683.html