def merge_time_and_score(list1:[],list2:[]):
last1=list1[-1]
last2=list2[-1]
if len(list1) >= len(list2):
keys = list1
values = list2 + [last2] * (len(list1) - len(list2))
else:
values = list2
keys = list1 + [last1] * (len(list2) - len(list1))
return {'time':keys,'socre':values}
统一多个不同长度的list并以某个值填充长度短的list,最终输出dict,Python
最新推荐文章于 2024-07-28 03:35:43 发布