我写了下面的程序写入到一个sqlite3的表:PythonGTK - 无法写入特殊字符到数据库
https://www.adrive.com/public/sJZKt3/program.py
它正常工作,试图挽救语言的特定字符,例如时除外:
AA,SS,C
当试图插入表中我得到以下错误消息:
SQL Error
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字符串?我想添加# - * - 编码:utf-8 - * - 会做的伎俩... – royskatt
在python2你必须解码字符串。请参阅[Unicode HOWTO](https://docs.python.org/2/howto/unicode.html)和[参考](https://docs.python.org/2/library/stdtypes.html#str .decode)获取信息。否则,你可以切换到默认使用unicode字符串的python3。 – elya5