使用fix_yahoo_finance这个包,这里提供的pdr_overrider()可以修复不能读取的问题
from pandas_datareader import data as pdr import fix_yahoo_finance as yf yf.pdr_override() # 用来修复,必要 # 获取数据 data = pdr.get_data_yahoo("SPY", start="2017-01-01", end="2017-04-30") #打印 print(data.head())