使用fix_yahoo_finance這個包,這裏提供的pdr_overrider()能夠修復不能讀取的問題ide
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())