str 和 bytes 转换

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)

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-05
  • 2021-10-14
  • 2022-12-23
  • 2022-12-23
  • 2021-09-06
猜你喜欢
  • 2022-12-23
  • 2021-11-19
  • 2021-10-16
  • 2022-02-04
  • 2022-02-13
相关资源
相似解决方案