zoukankan      html  css  js  c++  java
  • 【Python】去除Warning:You provided Unicode markup but also provided a value for from_encoding. Your from_encoding will be ignored.

    今天执行一爬虫脚本时出现以下Warning:

    C:hypy>python myblogSummary.py
    C:UsersufoAppDataLocalProgramsPythonPython37libsite-packagess4__init__.py:223: UserWarning: You provided Unicode markup but also provided a value for from_encoding. Your from_encoding will be ignored.
      warnings.warn("You provided Unicode markup but also provided a value for from_encoding. Your from_encoding will be ignored.")

    出现以上告警原因是因为有了这一句:

    soup= BeautifulSoup(html.text,'html.parser',from_encoding="utf-8");

    解决方案:

    将上一句修改成:

    soup= BeautifulSoup(html.text,'html.parser');

    原因:

    python3 缺省的编码是unicode, 再在from_encoding设置为utf8就重复了, 会被忽视掉,故而运行程序出现告警(当然不理这个告警也可以)。

    END

  • 相关阅读:
    glade2支持C++代码的输出(1)
    通用的信号量捕获打印调用栈接口
    xbmc的静态链接办法
    SVG图片资源较多的一个WIKI网站
    批量图片大小调整
    每日算法
    每日算法
    每日算法
    每日算法
    每日算法
  • 原文地址:https://www.cnblogs.com/heyang78/p/15315931.html
Copyright © 2011-2022 走看看