. 1 Print ( ' which is coded ' .encode ( ' UTF-. 8 ' )) # result B '\ xe8 \ XBF \ X99 \ XE6 \ X98 \ XAF \ XE7 \ XBC \ X96 \ XE7 \ XA0 \ X81' 2 Print ( ' this is coded ' .encode ( ' GBK ' )) # result B '\ XD5 \ XE2 \ XCA \ xc7 \ of xb1 \ xe0 \ XC2 \ XEB' . 3 . 4 Print (B ' \ xe8 \ XBF \ X99 \ XE6 \ X98 \ XAF \ XE7 \ XBC \ X96 \ XE7 \ XA0 \ X81 ' .decode ( ' UTF-. 8 ' )) # result' which is coded ' . 5 Print (B '\ XD5 \ XE2 \ XCA \ xc7 \ of xb1 \ xe0 \ XC2 \ XEB ' .decode ( ' GBK ' )) # result' which is decoded '
Python encoded encode () and the decoded decode ()
Guess you like
Origin www.cnblogs.com/Through-Target/p/12147972.html
Recommended
Ranking