jeudi 27 avril 2017

For loop list of datetimes with month as condition

y=[datetime.datetime,2016,4,27), datetime.datetime,2016,4,26)]
date1=[datetime.datetime,2016,4,28), datetime.datetime,2016,4,27)]

for item in y:
data2=[]
        for item in data1:
            if item.month==y.month and item.day==y.day:
                 data2.append(item.strftime('%d-%b-%y'))

This gives the error: 'list' object has no attribute 'month'. So how can I loop through a list of datetimes using the month as a condition? I'm using Python3

Aucun commentaire:

Enregistrer un commentaire