Python time.sleep() - How to Make a Time Delay in Python

John John (304)
3 minutes

Learn how to use Python's sleep function to make a timed delay.


import time

Howchoo is reader-supported. As an Amazon Associate, we may earn a small affiliate commission at no cost to you when you buy through our links.

We will first want to import Python's time module:

import time

This module ships with Python so it should be available on any system. Although it is not necessary for this guide, I highly recommend getting familiar with the time module. Read more about the time module here.

You can set a delay in your Python script by passing the number of seconds you want to delay to the sleep function:


This means you want the script to delay 5 seconds before continuing. The sleep function also accepts floats if you want to give a more precise number:


This will sleep for 1 second and 750 milliseconds. You can also use a float to delay for less than a second like this:


This will sleep for half of a second. You can and should read more about Python's sleep function here.

John John (304)
5 minutes

Continuous integration is pretty trendy, but despite that fact, it's also pretty useful. This guide will show you how to set up your first project in CircleCI.