bytes<-->str
a="hello" #str字符型
#str转换为bytes类型
b=a.encode("utf-8") 或 b=bytes(a,encoding="utf-8")
#bytes类型转换为str类型
c=b.decode("utf-8") 或 c=str(b,encoding="utf-8")
Python中数据类型的转换
阅读 28
2022-07-27
a="hello" #str字符型
#str转换为bytes类型
b=a.encode("utf-8") 或 b=bytes(a,encoding="utf-8")
#bytes类型转换为str类型
c=b.decode("utf-8") 或 c=str(b,encoding="utf-8")
相关推荐
精彩评论(0)