[英]How to access each element in object in google.colab?
I uploaded a file in googl colab and I tried to get the name of the file我在 googl colab 中上传了一个文件,我试图获取文件的名称
This is a result when I print upload.keys()
:这是我打印upload.keys()
时的结果:
dict_keys(['SSE.csv', 'SSE_origin.csv'])
I tried to access each element of object.我试图访问 object 的每个元素。 I only find this solution.我只找到这个解决方案。
from google.colab import files
uploaded = files.upload()
for name in uploaded.keys():
print(name)
Is there any other solution like indexing?有没有像索引这样的其他解决方案?
The problem is that you have a dict_keys object, not a list.问题是你有一个dict_keys object,而不是一个列表。 To use it as a list you have to convert it:要将其用作列表,您必须对其进行转换:
list(uploaded.keys())
Now you can access each element by indexing现在您可以通过索引访问每个元素
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.