这是我的代码(我使用的是 python 2.7 )
result = " '{0}' is unicode or something: ".format(mongdb['field'])
UnicodeEncodeError: 'ascii' codec can't encode character u'\xb0' in position 27: ordinal not in range(128)
看起来我从 mongodb 读取的字符串包含 unicode。它会抛出这个错误。如何修复它以将此 unicode 与自定义字符串 'is unicode or something:' 连接起来?
提前致谢
更新
result = u" '{0}' is unicode or something: ".format(mongdb['field'])
为我工作