How to convert string into list of array

nas

I have written code to generate all the dates for the given month:

nb_days = monthrange(2016, 2)[1]
dateDict = [datetime.date(year, month, day) for day in range(1, nb_days+1)]
outputItems = []
for dd in dateDict:
    outputItems.append(dd.strftime('%Y-%m-%d'))

My output is something like this:

['2016-02-01', '2016-02-02', '2016-02-03', '2016-02-04', '2016-02-05', '2016-02-06', '2016-02-07', '2016-02-08', '2016-02-09', '2016-02-10', '2016-02-11', '2016-02-12', '2016-02-13', '2016-02-14', '2016-02-15', '2016-02-16', '2016-02-17', '2016-02-18', '2016-02-19', '2016-02-20', '2016-02-21', '2016-02-22', '2016-02-23', '2016-02-24', '2016-02-25', '2016-02-26', '2016-02-27', '2016-02-28', '2016-02-29']

I need get result something like:

[('2016-02-01', '0', '0', '0'), ('2016-02-02', '0', '0', '0'), ('2016-02-03', '0', '0', '0'), ('2016-02-04', '0', '0', '0'), .....]
Jaimin Ajmeri

Try this outputItems.append( (dd.strftime('%Y-%m-%d'), '0', '0', '0') )

nb_days = monthrange(2016, 2)[1]
dateDict = [datetime.date(year, month, day) for day in range(1, nb_days+1)]
outputItems = []
for dd in dateDict:
    outputItems.append( (dd.strftime('%Y-%m-%d'), '0', '0', '0') )

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related