推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
sadfQED2
V2EX  ›  Python

Python 怎么关闭第三方模块的警告啊?

  •  
  •   sadfQED2 · Oct 26, 2019 · 4371 views
    This topic created in 2572 days ago, the information mentioned may be changed or developed.

    img

    这破玩意,吐血了,我完全看不到我自己的日志信息了,每秒刷几千条

    网上搜都说加

    import warnings
    
    warnings.filterwarnings('ignore')
    

    或者用

    python -W ignore ...
    

    然鹅都没有什么卵用啊

    5 replies  •  2019-10-29 08:34:28 +08:00
    hushao
    hushao
    Oct 26, 2019 via iPhone
    1
    图挂了...
    有错改错,没错设置日志级别
    sadfQED2
    sadfQED2
    OP
    Oct 26, 2019 via Android
    2
    @hushao 图没挂,要带梯子,第三方模块,没有设置日志级别的地方呀,而且这个输出是在 c 语言里面的
    hushao
    hushao
    Oct 26, 2019 via iPhone
    3
    python 调用 c ?在主程序里设置级别不行么?
    blueset
    blueset
    Oct 27, 2019
    4
    这东西怕不是 libpng 直接输出到 stderr 里面的?

    看了下 Stack Overflow 上面的讨论,看来改掉 /去掉 metadata 才是正道(?)。
    引用自: https://www.google.com/search?q=libpng+warning+iccp+known+incorrect+srgb+profile
    luckyc
    luckyc
    Oct 29, 2019
    5
    ```
    import warnings

    with warnings.catch_warnings():
    warnings.filterwarnings("ignore",category=DeprecationWarning)
    import pymssql #需忽略警告的模块

    print('Type your code here')
    ```
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   985 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 19:22 · PVG 03:22 · LAX 11:22 · JFK 14:22
    ♥ Do have faith in what you're doing.