search

Home  >  Q&A  >  body text

网络爬虫 - python sys 模块 设置编码老是报错

import sys
reload(sys)
sys.setdefaultencoding("utf-8")

我用的python2.7 eclipse-pydev,这上面第三行设置编码老是提示错误!不知道怎么回事。如下图第7行,前面这个红X,下面一条红线,意思就是说这行代码有错。


伊谢尔伦伊谢尔伦2781 days ago829

reply all(2)I'll reply

  • 高洛峰

    高洛峰2017-04-18 10:22:19

    You have to report the error. What is the error? It will be difficult for others to know where you went wrong.

    reply
    0
  • 怪我咯

    怪我咯2017-04-18 10:22:19

    Create a screenshot or copy the error code to see?
    Try sys.setdefaultencoding after import sys

        import sys
        sys.setdefaultencoding("utf-8")
        reload(sys)

    reply
    0
  • Cancelreply