Skip to content
Advertisement

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?

Advertisement

Answer

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

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement