I am trying to iterate a function over the list returned from rrule and keep getting “object has no attribute ‘getitem‘” message. Does that mean I first have to “parse” results from rrule to be able to use them for iteration?
Example code
for smoketest in rrule.rrule(rrule.HOURLY, dtstart=startD, until=endD):
print smoketest
dateID = smoketest[0:10]
hourID = smoketest[11:13]
Exact error is TypeError: ‘datetime.datetime’ object has no attribute ‘getitem‘.
Sorry if this sounds kind of dumb, This is my first in programming.
smoketestis adatetime.datetimeobject, not a string. What you see inprintis its string representation.datetime.datetimeobject offers much more.Do you need the
smoketestas date string and as time string? Use thestrftimemethod: