decode英文意思是 解碼,encode英文原意 編碼
字元串在Python內部的表示是unicode編碼,因此,在做編碼轉換時,通常需要以unicode作爲中間編碼, 即先將其他編碼的字元串解碼(decode)成unicode,再從unicode編碼(encode)成另一種編碼。
decode的作用是將其他編碼的字元串轉換成unicode編碼,如de('gb2312'),表示將gb2312編碼的字元串str1轉換成unicode編碼。
encode的作用是將unicode編碼轉換成其他編碼的字元串,如de('gb2312'),表示將unicode編碼的字元串str2轉換成gb2312編碼。