标签:enc byte bsp utf-8 code style decode int class
str与bytes的相互转化
中文
#str --->byte encode 编码 # s = ‘二哥‘ # b = s.encode(‘utf-8‘) # print(b) # # byte --->str decode 解码 # s1 = b.decode(‘utf-8‘) # print(s1)
英文
# s = ‘abf‘ # b = s.encode(‘utf-8‘) # print(b) # # byte --->str decode 解码 # s1 = b.decode(‘gbk‘) #或 s1 = b.decode(‘utf-8‘) # print(s1)
标签:enc byte bsp utf-8 code style decode int class
原文地址:https://www.cnblogs.com/aj-AJ/p/10801252.html