How to add a certain time delay to the code using Python

0 votes
Hi all. Pretty simple - My requirement is that I want to know how I could put a certain time delay of a particular duration into the code of my Python script.

I am working on learning Python and using this for a project of mine.

All help appreciated!
Feb 14, 2019 in Python by Anirudh
• 2,090 points
1,227 views

2 answers to this question.

0 votes

It is really simple. Check out the following code snippet:

import time
time.sleep(5)   # Delays for 5 seconds. You can also use a float value.

Also, check this out. I have another example for you where a piece of code is run once in a minute.

import time
while True:
    print("This prints once a minute.")
    time.sleep(60) # Delay for 1 minute (60 seconds).

Hope this helped!

answered Feb 14, 2019 by Nymeria
• 3,560 points
0 votes
You can use
time.sleep(duration in second)
answered Feb 14, 2019 by Shashank
• 1,370 points

Related Questions In Python

0 votes
2 answers

how to print the current time using python?

print(datetime.datetime.today()) READ MORE

answered Feb 14, 2019 in Python by Shashank
• 1,370 points
1,130 views
0 votes
1 answer

How to correctly return an a dictionary as an output in zappier code using python?

David here, from the Zapier Platform team. ...READ MORE

answered Dec 3, 2018 in Python by charlie_brown
• 7,720 points
1,661 views
0 votes
2 answers

How can I write a program to add two numbers using functions in python?

there is sum() function as a built ...READ MORE

answered Oct 25, 2020 in Python by anonymous
23,851 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,443 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
4,078 views
0 votes
3 answers

How to get the return value from a thread using python?

FWIW, the multiprocessing module has a nice interface for ...READ MORE

answered Dec 15, 2020 in Python by Roshni
• 10,480 points
107,808 views
0 votes
1 answer

How to use read a WSDL file from the file system using Python suds?

Hi, good question. It is a very simple ...READ MORE

answered Jan 21, 2019 in Python by Nymeria
• 3,560 points
8,321 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP