这里有一些想法。也许没有回应。我过去一直在玩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格式。在