我有Python程序,它会对某些任务进行排序并在一定延迟后执行它们。
请检查以下代码
import heapq
import dateutil
from dateutil.parser import *
from datetime import *
from time import sleep
import time
h = []
now = parse("Sat Oct 11 17:13:46 UTC 2003")
today = now.date()
tup1=(dateutil.parser.parse('13:00 5.5.2018'), 10, 3, 'Job 1')
# push items into queue:
heapq.heappush(h, tup1)
heapq.heappush(h, (dateutil.parser.parse('14:00 5.5.2018'), 10, 2, 'Job 2'))
heapq.heappush(h, (dateutil.parser.parse('14:00 5.5.2018'), 1, 10, 'Job 3'))
heapq.heappush(h, (dateutil.parser.parse('13:30 5.5.2018'), 1, 3, 'Job 4'))
try:
while True:
if h:
tuple=(heapq.heappop(h))
print(int(tuple[2]))
time.sleep(int(tuple[2]))
except KeyboardInterrupt:
print "exiting"
我如何修改现有列表中的内容,例如,如果我想访问作业4的日期值,以及如何在不弹出它们的情况下列出所有内容?