Emily Li
Emily Li

Reputation: 45

how to run python function again and again and never stop unless I stop it?

I am currently writing a python script. As I want it to check an API data in real time, so I want it to call the API function every 1 second. How should I done please?

Upvotes: -2

Views: 67

Answers (1)

Arghya Saha
Arghya Saha

Reputation: 5713

You can use the following code

import time
while True:
    call_api()
    time.sleep(1)

here call_api will be called until you stop the program by ctrl+c

Upvotes: 1

Related Questions