I am trying to scrape data using yfinance and have met a road block when trying to retrieve a ticker with no data, the error is - 7086.KL: No data found for this date range, symbol may be delisted
. How do I try catch this error? I've tried try catching it as seen in the code below but it still prints that error.
编码:
tickerdata = yf.Ticker("7086.KL")
try:
history = tickerdata.history(start="2019-06-01", end="2020-05-01")
except ValueError as ve:
print("Error")
关于如何解决这个问题的任何建议?感谢您的阅读。
您需要弄清楚抛出什么错误才能抓住它。
尝试这个:
Once you have the type of error, you can substitute it in instead of
ValueError