Python-打字机功能不起作用。大量延迟后打印整串
我目前正在学习Python,并且遇到了类型的作者效果。但是,当我应用代码时,它似乎不起作用。我感谢某人对为什么不起作用的看法。
当我运行代码时,它对3-4秒无能为力,然后打印WHOE字符串。我希望它在打印下一个角色之前,将单个角色打印出一个小延迟的时间。
import string
def typewriter_simulator(message):
for char in message:
print(char, end='')
if char in string.punctuation:
time.sleep(1)
time.sleep(.03)
print('')
def print_pause_type(message, delay=1):
typewriter_simulator(message)
time.sleep(delay)
print_pause_type("Hello!")
I am currently learning Python and I came across a type writer effect. But when I apply the code it does not seem to work. I would appreciate someone to provide their view as to why this does not work please.
When I run the code it does nothing for 3-4 secs then prints the whoe string. I am wanting it to print individual character a time with a small delay before printing the next character.
import string
def typewriter_simulator(message):
for char in message:
print(char, end='')
if char in string.punctuation:
time.sleep(1)
time.sleep(.03)
print('')
def print_pause_type(message, delay=1):
typewriter_simulator(message)
time.sleep(delay)
print_pause_type("Hello!")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论