zoukankan      html  css  js  c++  java
  • python2.7运行出现的Warning: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode

    运行出现如下错误

    uncode编码警告:在unicode等价比较中,把两个参数同时转换为unicode编码失败。中断并认为他们不相等。

    windows下的字符串str默认编码是ascii,而python编码是utf8

    解决方法:添加如下几行代码

    import sys  
      
    reload(sys)  
    sys.setdefaultencoding('utf8')  

    或者
    if sys.getdefaultencoding() != 'utf-8':
    reload(sys)
    sys.setdefaultencoding('utf-8')

    该解决方法同样适用于如下报错

    ascii' codec can't decode byte 0xe6 in position 31: ordinal not in range(128)
    

      

  • 相关阅读:
    ceph简易安装
    ceph安装
    nova计算节点部署
    onva控制节点部署
    nova介绍
    image部署
    glance镜像介绍
    keystone部署
    keystone介绍
    rabbimtq消息队列部署
  • 原文地址:https://www.cnblogs.com/robinunix/p/9019874.html
Copyright © 2011-2022 走看看