更新时间:2021-07-17 09:37:58
除非有什么阻止你这样做,把它放到一个线程中.
Unless there is something preventing you from doing so, just put it into a thread.
import threading
import time
class Typewriter(threading.Thread):
def __init__(self, your_string):
threading.Thread.__init__(self)
self.my_string = your_string
def run(self):
for char in self.my_string:
libtcod.console_print(0,3,3,char)
time.sleep(50)
# make it type!
typer = Typewriter(your_string)
typer.start()
# wait for it to finish
typer.join()
这将防止睡眠阻塞您的主要功能.
This will prevent the sleep blocking your main function.