Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> Python

Cách khắc phục cảnh báo lỗi thời (deprecation warning) của pylab.pause

Để khắc phục cảnh báo lỗi thời khi dùng phương thức không còn khuyến khích, ta dùng warnings.filterwarnings("ignore") trong mã.

Ví dụ

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()

Kết quả

Process finished with exit code 0