问题遇到的现象和发生背景
我用pickle.load()读取pkl文件时出现了错误显示
object.new(BlockManager) is not safe, use BlockManager.new()
问题相关代码,请勿粘贴截图
output = open('get_stock_price.pkl', 'rb')
get_stock_price = pickle.load(output)
```)
###### 运行结果及报错内容
![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/79547583864610.png "#left")
```python
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/var/folders/b2/mb61jycx1cj1py_69sf14qqm0000gn/T/ipykernel_1428/1963887105.py in <module>
1 output = open('get_stock_price.pkl', 'rb')
----> 2 get_stock_price = pickle.load(output)
~/anaconda/anaconda3/lib/python3.9/copyreg.py in _reconstructor(cls, base, state)
41 def _reconstructor(cls, base, state):
42 if base is object:
---> 43 obj = object.__new__(cls)
44 else:
45 obj = base.__new__(cls, state)
TypeError: object.__new__(BlockManager) is not safe, use BlockManager.__new__()
import pickle
我的解答思路和尝试过的方法
尝试改变语句,还是没有用,一样的报错
with open("get_stock_price.pkl",'rb') as f:
content = pickle.load(f,encoding='iso-8859-1')
print(content)
尝试将文件copyreg中的obj = object.new(cls)改成obj = cls.new()也没有用
我想要达到的结果
希望能够读取pkl中的数据QAQ