V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2019-10-26 14:04:31 +08:00 · 3470 次点击
    这是一个创建于 1636 天前的主题,其中的信息可能已经有所发展或是发生改变。

    img

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

    网上搜都说加

    import warnings
    
    warnings.filterwarnings('ignore')
    

    或者用

    python -W ignore ...
    

    然鹅都没有什么卵用啊

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

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

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

    print('Type your code here')
    ```
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3295 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 12:13 · PVG 20:13 · LAX 05:13 · JFK 08:13
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.