代码完美地工作,并生成股票信息,直到无限循环。Python给我一个错误。
data.to_excel("output.xlsx") ^ IndentationError: unexpected indent.
我试过卸载和重新安装pandas,但无济于事。代码如下。
import pandas as pd
from alpha_vantage.timeseries import TimeSeries
import time
api_key = 'xxxxxxxxxxxxxxxxx'
ts = TimeSeries(key=api_key, output_format='pandas')
data, meta_data = ts.get_intraday(symbol='MSFT', interval = '1min', outputsize = 'full')
print(data)
i = 1
while i == 1:
data, meta_data = ts.get_intraday(symbol='MSFT', interval = '1min', outputsize = 'full')
data.to_excel("output.csv")
time.sleep(60)
检查你是否混合了空格和制表符进行缩进。当你从不同的源头复制和粘贴代码时,这有时会意外地发生。