Website Design United States, Website Design California, Website Designing United States, Website Designing California

Using sleep to wait a certain amount before continuing - Python

The program uses Python's sleep() function to pause the program (and free up any system resources its using while it does so) and then continues, so this will print a number once every second.

You can use floating point numbers with Python's sleep, so
sleep(0.1)
will make the program sleep for 1/10 of a second.

#!/usr/bin/python

from time import sleep

num = 1
while(True):
sleep(1)
print num
num += 1


WEB DESIGN INDIA
42 B Malviya Nagar , New Delhi-110017

Skype: manmeetsi
Email: support.webdesignindia@gmail.com
Tel: 91-011-40502005, 9810067295

 















 


© 2008-2009 dotnet4all.com