yfinance“history”函数在我的python会话中不起作用,如何调试它?

wbrvyc0a  于 2021-09-08  发布在  Java
关注(0)|答案(0)|浏览(280)

我是python新手,我正在尝试运行一些与股价相关的项目。
然而,历史函数对我来说永远不起作用。

import yfinance as yf

msft = yf.Ticker("MSFT")
msft.info
hist = msft.history(period="max")

.info运行正常。但是,历史记录会产生以下错误:

Traceback (most recent call last):
  File "<pyshell#17>", line 1, in <module>
    hist = msft.history(period="max")
  File "C:\Users\thoma\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\yfinance\base.py", line 157, in history
    data = data.json()
  File "C:\Users\thoma\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\models.py", line 900, in json
    return complexjson.loads(self.text,**kwargs)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1776.0_x64__qbz5n2kfra8p0\lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1776.0_x64__qbz5n2kfra8p0\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1776.0_x64__qbz5n2kfra8p0\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

有人知道这可能是什么原因吗?或者如何调试它?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题