当前位置:   article > 正文

UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting

unicode equal comparison failed to convert both arguments to unicode - inter
C:\Python27\lib\site-packages\itchat\storage\__init__.py:82: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
  if any([m.get(k) == name for k in ('RemarkName', 'NickName', 'Alias')]):

name='张三'
python2.7中文比对时出现以上错误,由于中文windows字符串str默认编码是ascii,python编码是utf8所以报错
解决办法:代码中加入以下代码

import sys
reload(sys)
sys.setdefaultencoding('utf8')
本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/酷酷是懒虫/article/detail/882509
推荐阅读
相关标签
  

闽ICP备14008679号