b = b"example" # bytes object s = "example" # str object sb = bytes(s, encoding = "utf8") # str to bytes 或者:sb = str.encode(s) # str to bytes bs = str(b, encoding = "utf8") # bytes to str 或者:bs = bytes.decode(b) # bytes to str