I am sure there are easier ways to do this, but I am not sure why I keep getting a TypeError.
import datetime
getdate = datetime.date.today()
thirty = datetime.timedelta(days=30)
last_month = getdate - thirty
print json.dumps(api.get_zone_stats(3, "daily", "%s", "%s" %(last_month, getdate)))
Traceback (most recent call last):
…
TypeError: not all arguments converted during string formatting
The problem is here:
The
%operator works on the previous string only:You have two variables for one single
%s.Try this:
or this: