python decoding and encoding issues
. 1 . Decode commonly known as decoding , the decoded unicode encoded into, for example, a string variable str is utf-8 encoded using str.decode ( 'utf-8') , is to utf-8 encoded decoded into unicode encoding.
2. encode known as encoding , the encoded into unicode other coding, for example a unicode string variable str is encoded using str.encode ( 'GBK') , is to unicode encoded into GBK .
3 . Unicode known as Unicode , common throughout the world. (Equivalent to the intermediary)
4. Then the question is, UTF. 8- encoded how to convert to gbk encoding. Of course, the solution is to find an intermediary -----> Unicode Unicode
For example: str string variable is utf-8 encoded, converted into the first unicode , encoding to encode the GBK coding.
Code: str.decode ( 'UTF-. 8') encode ( 'GBK').
5. vice versa, go first to the intermediary.
.unicode