首页 > 解决方案 > 如何在 Python 中进行调度作业以弹出列表中的元素?

问题描述

我想string为每个给定的时间间隔弹出下面列表的每个元素。

我在最后尝试了以下代码,但每次它只获取最后一个元素。

import schedule
import time
def job():
    #print("I'm working...")
    string = [1, 2, 3, 4]
    print (string.pop())



schedule.every(0.1).minutes.do(job)
schedule.every().hour.do(job)
schedule.every().day.at("10:30").do(job)

while 1:
    schedule.run_pending()
    time.sleep(1)

我得到的结果是4 4 4 4. 我期待4 3 2 1

标签: pythonschedule

解决方案


推荐阅读