轉自: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