python字符串str和字节数组相互转化

来源:互联网 发布:好看的战争电影知乎 编辑:程序博客网 时间:2024/05/29 15:47
# 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)  


0 0
原创粉丝点击