python - 文件打开困难
问题描述
我不想将 goog.npz 文件保存在下面建议的目录中,而是将其保存在这里:
file_path = 'C:/Users/.../goog.npz'
然后将 r (下面)替换为读取存储位置中的文件的内容。谢谢您的帮助!
# Load a numpy record array from yahoo csv data with fields date, open, close,
# volume, adj_close from the mpl-data/example directory. The record array
# stores the date as an np.datetime64 with a day unit ('D') in the date column.
with cbook.get_sample_data('goog.npz') as datafile:
r = np.load(datafile)['price_data'].view(np.recarray)
解决方案
只需在方法中指定文件的整个路径get_sample_data
:
with cbook.get_sample_data('C:Users/.../goog.npz') as datafile:
r = np.load(datafile)['price_data'].view(np.recarray)
推荐阅读
- branch - 如何创建没有注释的 ClearCase 分支类型?
- json - Ansible:使用 --extra-vars 时 JSON 无效
- laravel - 如何使用 Laravel 的验证助手对有效持续时间进行功能测试?
- mysql - PHP OOP INSERT INTO 仅在数据库中插入 NULL
- python - SQLAlchemy - 继承列的不同名称
- c++ - noexcept(auto) 自动推断函数是否可以声明 noexcept
- mysql - 如何将 MySQL 转储转换为 SQL Server 格式
- adobe - 在 Acrobat 中检查已删除的项目
- javascript - 如何在 React 中全局共享库?
- java - java中的坐标验证