python 中的延迟文本
Delayed text in python
类似于我的上一个问题:。我需要在 python 中制作更高效的延迟文本。我试图改变其他功能以使其工作,但我无法使其工作。
import time
msg = "helloworld"
for char in msg:
print char
time.sleep(1) #seconds
你试过这样的事情吗?
def delay_print(text, delay):
for i in text:
time.sleep(delay)
print(i, end='')
sys.stdout.flush()
print()
这只是循环遍历给定的 text
并使用 end=''
在循环完成之前不打印新行
类似于我的上一个问题:
import time
msg = "helloworld"
for char in msg:
print char
time.sleep(1) #seconds
你试过这样的事情吗?
def delay_print(text, delay):
for i in text:
time.sleep(delay)
print(i, end='')
sys.stdout.flush()
print()
这只是循环遍历给定的 text
并使用 end=''
在循环完成之前不打印新行