gpt4 book ai didi

python - yfinance "history"函数在我的 python session 中不起作用,我该如何调试?

转载 作者:行者123 更新时间:2023-12-04 07:23:53 29 4
gpt4 key购买 nike

我是 python 新手,我正在尝试运行一些与股价相关的项目。
但是 .history 功能对我来说从来没有用过。

import yfinance as yf

msft = yf.Ticker("MSFT")
msft.info
hist = msft.history(period="max")
.info 运行良好,但是 .history 产生以下错误:
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)
有谁知道这可能是什么原因造成的?或者如何去调试它?

最佳答案

你应该升级yfinance。在命令行上运行这个:

pip install yfinance==0.1.62

关于python - yfinance "history"函数在我的 python session 中不起作用,我该如何调试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68325669/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com