Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python

แก้ Deprecation Warning ของ pylab.pause ใน Matplotlib

ใช้ warnings.filterwarnings("ignore") เพื่อปิด warning ชั่วคราว

ตัวอย่างโค้ด


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