python创建sqlite3 unicode error_在python2.7.3中使用sqlite3的Unicode

我试图插入到一个表中,但似乎我打开的文件中有非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。在

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值