I have 3 lists, yearlist, monthlist and daylist. I'm trying to combine all 3 and add strings between them.
for i in range(0,j):
singledate = 'datetime(year=' + yearlist[i] + ', month=' + monthlist[i] + ', day=' + daylist[i] + ')'
datelist.append(singledate)
print singledate
print datelist
This prints singledate as datetime(year=2009, month=01, day=15)
, but datelist as ['datetime(year=2009, month=02, day=14)', 'datetime(year=2009, month=01, day=15)']
Is it possible to remove all " ' " in datelist? Thanks
If you are looking for datetime
, You don't want to use string, Try something like this,
In [12]: import datetime
In [13]: datelist = [datetime.datetime(yearlist[i],monthlist[i],daylist[i]) for i in range(0,j)]
Result
[datetime.datetime(2009, 1, 14, 0, 0), datetime.datetime(2009, 2, 15, 0, 0)]
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments