如何修复 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