#bytes object
byte = b"byte example"
byte = b"byte example"
# str object
str = "str example"
str = "str example"
# str to bytes 字符串轉字節
bytes(str, encoding="utf8")
bytes(str, encoding="utf8")
# bytes to str 字節轉字符串
str(bytes, encoding="utf-8")
str(bytes, encoding="utf-8")
# an alternative method
# str to bytes 字符串轉為字節
str.encode(str)
# str to bytes 字符串轉為字節
str.encode(str)
# bytes to str 字節轉為字符串
bytes.decode(bytes)
bytes.decode(bytes)
