1、錯誤內容:You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings.
錯誤描述:Python中使用Sqlite3模塊進行db文件處理時出現;
知識點與解決:
conn?=?sqlite3.connection("?...?")
conn.text_factory?=?str
設置python使用什么類型來處理sqlite3的text類型,默認是unicode,所以才會產生
OperationalError:?Could?not?decode?to?UTF-8?column?'name'?with?text?'國內其他'
這個錯誤
因為從數據庫中取出數據時,是gbk編碼(因為你上次存進去的是gbk)
conn.text_factory的默認值是unicode,python會嘗試將text類型的字段轉換成unicode,就產生了錯誤