标签:class bytes 类型 odi coding pre utf-8 byte 结果
#----string to bytes------ # 方法一:直接复制bytes类型 b‘<str>‘ b = b‘Hello World‘ print(type(b)) print(b) # 方法二:转换 s = ‘Hello World‘ b = bytes(s,encoding=‘utf-8‘) print(type(b)) print(b) #----bytes to string------ s = str(b,encoding=‘utf-8‘) print(type(s)) print(s) #----执行结果------ <class ‘bytes‘> b‘Hello World‘ <class ‘bytes‘> b‘Hello World‘ <class ‘str‘> Hello World
标签:class bytes 类型 odi coding pre utf-8 byte 结果
原文地址:https://www.cnblogs.com/leoshi/p/12300584.html