python的warnings.filterwarnings(“ignore“)

在python中运行代码经常会遇到的情况是------代码可以正常运行但是会提示警告,如果想要去掉这些警告,可以使用python的warnings.filterwarnings("ignore")函数。

代码:

cpp 复制代码
import warnings
warnings.filterwarnings('ignore')

看一下这个函数:

cpp 复制代码
warnings.filterwarnings(action, 
						message='', 
						category=Warning, 
						module='', 
						lineno=0, 
						append=False)
  • action 可以填以下的值:
  • 示例
相关推荐
曲幽1 天前
FastAPI 身份验证总踩坑?这份 FastAPI Users “避坑指南”请收好
python·fastapi·web·jwt·oauth2·user·authentication
装不满的克莱因瓶1 天前
掌握 RNN 与 LSTM 模型结构
人工智能·python·rnn·深度学习·神经网络·ai·lstm
何以解忧,唯有..1 天前
Python包管理工具pip:从入门到精通
开发语言·python·pip
金銀銅鐵1 天前
用 Tkinter 实现简单的猜数字游戏
后端·python
copyer_xyf1 天前
Python 模块与包的导入导出
前端·后端·python
ice8130331811 天前
【Python】Matplotlib折线图绘制
开发语言·python·matplotlib
copyer_xyf1 天前
Python venv 虚拟环境
前端·后端·python
林爷万福1 天前
GitHub 开源光谱数据处理项目推荐
python·光纤光谱仪
copyer_xyf1 天前
Python 如何同时做很多事:进程、线程、协程
前端·后端·python
Full Stack Developme1 天前
Spring Bean 依赖注入
python·spring·log4j