简体   繁体   中英

Convert year from unicode format to python's datetime format

I have only year parameter as input in the following manner:

2014,2015,2016

I want to convert each element from my list into python's datetime format. Is it possible to do this kind of things if the only given parameter is the year ?

Just set month and day manually to 1

 from datetime import date
 YearLst = [2014,2015,2016]
 map(lambda t: date(t, 1, 1),YearLst)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM