如何在 python 2.7.9 中使用 while 循环缓慢打印

How to print slowly with a while loop in python 2.7.9

我正在尝试更慢地打印以下循环的每个迭代(以便看到打印图像的人可以在图像消失得太快之前真正辨别出它是什么)。欢迎任何帮助。以下代码似乎并没有减慢任何速度,即使我将整数更改为不同的数字也是如此。我不明白为什么它不起作用。

 import time 
 while True: 

      print  """There are normally 55 lines of strings here, but for readability sake I have deleted them and inserted this text instead."""
 time.sleep(5)

因为对 sleep 的调用是 while 循环之外,所以您将 运行 all打印,然后才让程序休眠。

缩进对 sleep 的调用以将其包含在循环中。

错误的缩进应该是

import time 

while True: 
    print  """There are normally 55 lines of strings here, but for readability sake I have deleted them and inserted this text instead."""
    time.sleep(5)