Typing effect in Python

前端 未结 7 1844
被撕碎了的回忆
被撕碎了的回忆 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:52

    To make it easier, You should put a sys.stdout.flush and a def function. For example:

        import sys
        import time
    
        def print_slow(str):
            for char in str:
                time.sleep(.1)
                sys.stdout.write(char)
                sys.stdout.flush()
    
    print_slow('Hello')
    

    This should work because I have tested it. The def makes it easier to write out your strings and you can custom it anyway you like. (:

    0 讨论(0)
提交回复
热议问题