hickle NameError:名称“文件”未定义

2024-02-01

请向我解释为什么我会遇到这个错误。我已经在ubuntu中安装了python 3.5

import os
import hickle as hkl
import numpy as np
array_obj = np.ones(32768, dtype='float32')
hkl.dump(array_obj, 'test.hkl', mode='w')

结果是

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\hickle.py", line 308, in dump
    h5f = file_opener(file_obj, mode, track_times)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\hickle.py", line 148, in file_opener
    if isinstance(f, file):
NameError: name 'file' is not defined

Hickle不支持Python3(它使用Python3不支持的file()函数),但是你可以找到修改版 https://github.com/karandwivedi42/hickle在 GitHub 上,或者直接使用 Python2。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

hickle NameError:名称“文件”未定义 的相关文章

随机推荐