如何消除python中的VisibleDeprecationWarning\ DeprecationWarning等类似警告:


转自:https://blog.csdn.net/weixin_41884148/article/details/88783554

如何消除python中的VisibleDeprecationWarning\ DeprecationWarning等类似警告:

我们在写相关代码时总会有一些警告,虽然并不影响结果,但是很影响美观。如果在不急于解决警告的情况下我们可以选择一些方法进行忽略。
eg:

VisibleDeprecationWarning: boolean index did not match indexed array along dimension 0;

DeprecationWarning: This function is deprecated. Please call randint(0, 1 + 1) instead;

添加代码如下:

import warnings
warnings.filterwarnings("ignore", category=Warning)

原文链接:https://blog.csdn.net/weixin_41884148/article/details/88783554


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM