printing slowly (Simulate typing)
In Python 2.x you can use sys.stdout.write
instead of print
:
for letter in str:
sys.stdout.write(letter)
time.sleep(.1)
In Python 3.x you can set the optional argument end
to the empty string:
print(letter, end='')
This is my "type like a real person" function:
import sys,time,random
typing_speed = 50 #wpm
def slow_type(t):
for l in t:
sys.stdout.write(l)
sys.stdout.flush()
time.sleep(random.random()*10.0/typing_speed)
print ''
Try this:
def print_slow(str):
for letter in str:
sys.stdout.write(letter)
sys.stdout.flush()
time.sleep(0.1)
print_slow("Type whatever you want here")