1. First gather the usage of the decode () decoding and Encode () codes seen in the past few days
Bytes and STR are byte packets and strings, and Python3 will distinguish between bytes and STR, and will not mix these two. A string can be encoded into a byte packet, and a byte packet can be decoded into a string.
As follows
Illegal! is a string that is encoded into a byte packet and can see B ' this identity.
We don't care how they are represented internally, and each character in the string is saved in a few bytes. It is only when the strings are encoded into a byte package (for example, to send them on a channel) or decoded from a byte packet (reverse operation) that we begin to pay attention to this.
If the content of a page is read in bytes, it needs to be decoded into a string, JSON format, which requires a string. If the data being read is a JSON-formatted string, we can use the loads method in the module JSON provided by Python to turn it into a dictionary.
Cross-conversion between different encodings in 2.python
in Python, the Unicode type is used as the underlying type of the encoding, i.e. Decode encode
str ———— > Unicode ———— > str
About Python decode () and encode ()