- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to suspend the calling thread for few seconds in Python?
You can suspend the calling thread for a given time in Python using the sleep method from the time module. It accepts the number of seconds for which you want to put the calling thread on suspension for.
Example
import time while(True): print("Prints every 10 seconds") time.sleep(10)
Output
Prints every 10 seconds Prints every 10 seconds Prints every 10 seconds ...
Each of the above statements will be printed every 10 seconds.
Note that this method also supports floating point values so you can also put the calling thread to sleep for fractions of seconds.
Advertisements
To Continue Learning Please Login
Login with Google