參考
http://blog.csdn.net/gukesdo/article/details/7336936
http://www.jb51.net/article/17560.htm
各種碼 ascii碼 unicode碼 utf8碼 gb2312碼 gbk碼
字符串在Python內部的表示是unicode編碼,因此,在做編碼轉換時,通常需要以unicode作爲中間編碼,即先將其他編碼的字符串解碼(decode)成unicode,再從unicode編碼(encode)成另一種編碼。
decode的作用是將其他編碼的字符串轉換成unicode編碼,如str1.decode('gb2312'),表示將gb2312編碼的字符串str1轉換成unicode編碼。
encode的作用是將unicode編碼轉換成其他編碼的字符串,如str2.encode('gb2312'),表示將unicode編碼的字符串str2轉換成gb2312編碼。
數據庫中的編碼問題 如下
print s._getItemByTaxRegCode("320100100389067")[2].encode('latin-1').decode('gbk')