我知道也有类似的问题,但答案截然不同,而且有点令人困惑。
我有这个字符串:
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')
The sqlite3
库将在插入时正确编码,在选择时再次解码。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)