开发者

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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜