我在执行 plt.figure() 时正在初始化空图。它打开很好。但是,一旦我实现了以下代码,打开的图形就没有响应。知道为什么这个窗口没有响应吗?
import matplotlib.pyplot as plt
plt.figure() # It opens graph fine
with open("data.txt") as file_data:
while True:
pass
我在执行 plt.figure() 时正在初始化空图。它打开很好。但是,一旦我实现了以下代码,打开的图形就没有响应。知道为什么这个窗口没有响应吗?
import matplotlib.pyplot as plt
plt.figure() # It opens graph fine
with open("data.txt") as file_data:
while True:
pass
该while True:循环将导致 python 解释器认为还有更多事情要做。它将保持无响应,直到它“完成”那个循环,它永远不会这样做。删除循环或替换pass为break