Adding to an array every 1 second in python
Can anyone please help me to add to an array every second? thanks.开发者_如何转开发
You can simply do time.sleep(secs)
to create a delay in a script.
import time
ls = []
add = True
while add:
ls.append(0)
time.sleep(1)
For 10 times a second, use a float in sleep
from time import sleep
while True:
y.append(k[3])
sleep(0.1)
精彩评论