Code snippets to show you how to convert string to bytes and vice versa.
1. To convert a string to bytes.
data = "" #string
data = "".encode() #bytes
data = b"" #bytes
- To convert bytes to a String.
data = b"" #bytes
data = b"".decode() #string
data = str(b"") #string
P.S Tested with Python 3.4.3
8万+

被折叠的 条评论
为什么被折叠?



