我需要帮助来遍历这个函数中名为'TimeO'
和'TimeC'
的数据字典列
Data_Dict = {'TimeO': ['9:00:00', '10:00:00'] 'TimeC': ['14:00:00', '16:00:00']}
x
应该是来自TimeO
的值,y
应该是来自TimeC
的值
我不知道如何迭代这些值
def timed_duration():
opening = datetime.strptime(x, '%H:%M:%S')
closing = datetime.strptime(y, '%H:%M:%S')
sec =(closing-opening).total_seconds()
hour = sec/3600
return(hour)
timed_duration()
x
和y
应该遍历400条记录,但我不知道该怎么办
考虑到您的数据如下所示:
这将创建一个名为
hours
的列表,其中填充函数的结果。zip()
允许您同时遍历这两个对象相关问题 更多 >
编程相关推荐