Python: alle Monate in Reichweite bringen?
Ich möchte alle Monate zwischen jetzt und August 2010 als Liste mit folgendem Format erhalten:
['2010-08-01', '2010-09-01', .... , '2016-02-01']
Right now das ist, was ich habe:
months = []
for y in range(2010, 2016):
for m in range(1, 13):
if (y == 2010) and m < 8:
continue
if (y == 2016) and m > 2:
continue
month = '%s-%s-01' % (y, ('0%s' % (m)) if m < 10 else m)
months.append(month)
Was wäre ein besserer Weg, um dies zu tun?