python mysql unicode_Python与MySql unicode问题

这里有一些想法。也许没有回应。我过去一直在玩python/mysql/utf-8/unicode,我记得的是:

查看Saltstack mysql模块的注释:# MySQLdb states that this is required for charset usage

# but in fact it's more than it's internally activated

# when charset is used, activating use_unicode here would

# retrieve utf8 strings as unicode() objects in salt

# and we do not want that.

#_connarg('connection_use_unicode', 'use_unicode')

connargs['use_unicode'] = False

_connarg('connection_charset', 'charset')

我们看到,为了避免改变结果字符串,use_unicode被设置为False,而字符集(可能是utf-8)被设置为参数。使用unicode更像是一个“请求”,以unicode字符串的形式获取响应。在

现在,关于消息UnicodeEncodeError:'utf-8'codec cannot encode can encode character'\udcd1'**。您使用的是**unicode,但您告诉模块它是utf-8。除非将unicode字符串编码为utf-8,否则它不会utf-8。在

也许你应该试试:

^{pr2}$

至少在python3中,这是必需的,因为默认情况下,你的“какоакой-аоекст”不是utf-8格式。在

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值