python字符串str和字节数组相互转化方法
时间:2021-07-25 08:39:25|栏目:Python代码|点击: 次
实例如下:
# bytes object b = b"example" # str object s = "example" # str to bytes bytes(s, encoding = "utf8") # bytes to str str(b, encoding = "utf-8") # an alternative method # str to bytes str.encode(s) # bytes to str bytes.decode(b)
栏 目:Python代码
本文地址:http://www.codeinn.net/misctech/161299.html






