我已经搜索了这个问题的几个答案,但是,它们并不能解决我的问题。
我当前的代码是:
from datetime import datetime, timedelta
startDate = '2018-02-01'
endDate = '2018-03-01'
startDate = datetime.strptime(endDate, '%Y-%m-%d')
endDate = datetime.strptime(endDate, '%Y-%m-%d')
for i in range(2,10):
returns.loc[startDate+datetime.timedelta(days=10*i):endDate+(10*i)+datetime.timedelta(days=10*i)]
给出: AttributeError:类型对象“ datetime.datetime”没有属性“ timedelta”