- # 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 str与bytes之间的转换
猜你喜欢
转载自blog.csdn.net/golddaniu/article/details/80493194
今日推荐
周排行