我试图插入到一个表中,但似乎我打开的文件中有非ascii字符。这是我得到的错误: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.
所以在做了一些研究之后,我试着在代码中加入:encode("utf8","ignore")
然后给了我一个错误:UnicodeDecodeError: 'ascii' codec can't decode byte 0x92 in position 9: ordinal not in range(128)
然后我试着用codecs库打开文件如下:
^{pr2}$
这给了我一个错误:newchars, decodedbytes = self.decode(data, self.errors)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x92 in position 0: invalid start byte
然后,我用utf-16代替utf-8,看看它是否有用,我得到了一个错误:raise UnicodeError,"UTF-16 stream does not start with BOM"
UnicodeError: UTF-16 stream does not start with BOM
我完全没主意了。。。
如果有用的话,我也在用Ubuntu。在