[[+content_image]]
A
A
Avrong2016-01-24 22:01:21
Python
Avrong, 2016-01-24 22:01:21

How to get multiple days of the months of the current year?

I would like it in this form: [[1, 2, 3, 4, ... , 31][1, 2, 3, 4, ... , 28]...]
Are there ready-made functions for such generation or how receive and arrange so days and months?

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
A
Anatoly Scherbakov, 2016-01-24
@Avrong

import calendar

year = 2015
print [
    list(range(1, calendar.monthrange(year, month)[1] + 1))
    for month in range(1, 13)
]

https://docs.python.org/2/library/calendar.html#ca...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question