【发布时间】:2020-03-28 19:45:03
【问题描述】:
我有两个列表 time_list 带有日期时间和 name_list 名称分别相互映射。
time_list = [datetime.datetime(2020, 3, 28, 18, 49, 36, tzinfo=tzutc()),
datetime.datetime(2020, 3, 28, 18, 54, 53, tzinfo=tzutc()),
datetime.datetime(2020, 3, 28, 19, 5, 28, tzinfo=tzutc()),
datetime.datetime(2020, 3, 28, 18, 59, 56, tzinfo=tzutc()),
datetime.datetime(2020, 3, 28, 18, 55, 42, tzinfo=tzutc())]
name_list = [a,b,c,d,e]
如何在time_list中找到哪个name_list的时间最近?
在上面的例子中:
time_list[2] 拥有最新的 w.r.t name_list[2]
预期输出:
most_recent_name_list = ['c']
【问题讨论】:
-
基于最近的日期时间 - 从其他列表中获取值。
-
您能否澄清
name_list的内容,以及问题所在?
标签: python list datetime python-datetime