我只有年份参数作为输入,方式如下:
2014,2015,2016
我想将列表中的每个元素转换为python的日期时间格式。如果唯一给定的参数是年份,是否可以做这种事情?
只需手动将月份和日期设置为 1
from datetime import date
YearLst = [2014,2015,2016]
map(lambda t: date(t, 1, 1),YearLst)