Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can the execution of statements in Python be delayed?

I want it to run the first line print 1 then wait 1 second to run the second command print 2, etc.

Pseudo-code:

print 1
wait(1 seconds)
print 2
wait(0.45 seconds)
print 3
wait(3 seconds)
print 4
like image 411
rectangletangle Avatar asked Jul 25 '10 02:07

rectangletangle


People also ask

Is there a delay command in Python?

Python time sleep function is used to add delay in the execution of a program. We can use python sleep function to halt the execution of the program for given time in seconds.


1 Answers

time.sleep(seconds)

import time

print 1
time.sleep(1)
print 2
time.sleep(0.45)
print 3
time.sleep(3)
print 4
like image 172
NullUserException Avatar answered Oct 03 '22 17:10

NullUserException