【发布时间】:2018-07-07 04:53:28
【问题描述】:
我是 python 新手,我使用 Google Colab 。我将train_data.npy 上传到 google Colab,然后我想使用它。根据这个链接How to import and read a shelve or Numpy file in Google Colaboratory?
当我运行我的代码时,我遇到了这个错误:
TypeError: 'dict_keys' 对象不支持索引
这是我的代码:
uploaded = files.upload()
for fn in uploaded.keys():
print('User uploaded file "{name}" with length {length} bytes'.format(
name=fn, length=len(uploaded[fn])))
with open('train_data.npy', 'w') as f:
f.write(uploaded[uploaded.keys()[0]])
谢谢
【问题讨论】:
标签: python google-colaboratory