如何修复 pylab.pause 附带的弃用警告?
matplotlibpythondata visualization
要修复使用弃用方法时出现的弃用警告,我们可以在代码中使用 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