阅读背景:

python 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) # bytes object
  b = b"example"

  # str objec



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: