Typing effect in Python

前端 未结 7 1842
被撕碎了的回忆
被撕碎了的回忆 2021-01-13 00:05

I want to make such program which reads characters from a string and prints each character after some delay so its look like typing effect.

Now my problem is sleep f

7条回答
  •  孤城傲影
    2021-01-13 00:41

    I have a similar answer to @Jon Vorcak,

    we use a function, with his code

    #you can also call it whatever you want
    def type(text):
      words = text
      for char in words:
        time.sleep(0.2)
        sys.stdout.write(char)
        sys.stdout.flush()
    type("hi")
    

提交回复
热议问题