如何修復 pylab.pause 隨附的棄用警告?


要修復在使用已棄用的方法時出現的棄用警告,我們可以在程式碼中使用 warnings.filterwarnings("ignore")。−

示例

from matplotlib import pyplot as plt, pylab as pl
import warnings

plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

warnings.filterwarnings("ignore")

pl.pause(0)
plt.show()

輸出

Process finished with exit code 0

更新時間: 2021 年 6 月 5 日

177 次瀏覽

開啟你的 職業生涯

透過完成課程獲得認證

開始學習
廣告
© . All rights reserved.