Python将UTF8字符串插入SQLite

Python将UTF8字符串插入SQLite,python,sqlite,encoding,utf-8,Python,Sqlite,Encoding,Utf 8,我知道也有类似的问题,但答案是不同的,有点混乱 我有这个字符串: titulo = "Así Habló Zaratustra (Cómic)" 当我尝试将其插入SQLite数据库时,我得到错误: sqlite3.ProgrammingError: You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = s

我知道也有类似的问题,但答案是不同的,有点混乱

我有这个字符串:

titulo = "Así Habló Zaratustra (Cómic)"
当我尝试将其插入SQLite数据库时,我得到错误:

sqlite3.ProgrammingError: 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.

我做了几件事都没有成功。请提供帮助。

执行它告诉您的操作,并改用
unicode
值:

titulo_unicode = titulo.decode('utf8')
sqlite3
库将在插入时正确编码,在选择时再次解码