Python string、bytes之间的转换 Posted by Judson Leigh | 1月 7, 2019 | Python | 0 | # bytes对象 b = b"example" # string对象 s = "example" # string转bytes bytes(s, encoding = "utf8") # bytes转string str(b, encoding = "utf-8") # 另一种方法 # string转bytes str.encode(s) # bytes转string bytes.decode(b)
近期评论