startdate = datetime.date(2018,1,1)
expirydate = datetime.date(2018,1,4)
data = dict()
for x in range(0,3):
for y in range(1,8):
data [y] = get_history(symbol="BANKNIFTY",
start= startdate,
end= startdate,
index=True,
option_type='CE',
strike_price= 27000,
expiry_date=expirydate)
startdate += datetime.timedelta(days=1)
expirydate += datetime.timedelta(days=7)
循环运行良好,但只给了我最后一组值,即当 x = 3 时。其余所有先前的值都被覆盖。