python3 str和bytes转换
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)
文章对您有帮助,开心可以打赏我,金额随意,欢迎来赏!
需要电子方面开发板/传感器/模块等硬件可以到我的淘宝店逛逛