gpt4 book ai didi

python - 从 urllib2 隐藏 UserWarning

转载 作者:行者123 更新时间:2023-12-05 08:44:14 30 4
gpt4 key购买 nike


我使用带有密码管理器的开启器,当我第一次使用我的开启器时,我收到了以下警告消息:

/usr/lib/python2.7/urllib2.py:894: UserWarning: Basic Auth Realm was unquoted
url, req, headers)

我的应用似乎运行良好,但我该如何隐藏此消息?

附言:我使用:

Python 2.7.3 (default, Jan  2 2013, 16:53:07) 
[GCC 4.7.2] on linux2

最佳答案

使用 warnings module过滤掉代码中的特定警告:

import warnings

warnings.filterwarnings("ignore", category=UserWarning, module='urllib2')

关于python - 从 urllib2 隐藏 UserWarning,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14789631/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com