在学习python中遇到了提示“TypeError: list indices must be integers or slices, not str”报错。查询资料后得到了解决
TypeError: list indices must be integers or slices, not str

这里的提示意思是list的索引必须是整数或者片,而不是str
通过调试我的代码发现,我这里的datas中的数据是如下图所示
这是因为我这里的datas中有很多的dict,所以取不到对应的键值对.
所以具体解决办法:
herf = datas[0]["uri"]
参考资料:https://blog.csdn.net/zjiang1994/article/details/52679429
本文解决了在Python编程中遇到的TypeError:list indices must be integers or slices, not str错误。错误原因是尝试用字符串作为列表的索引,而列表只接受整数或切片作为索引。文中提供了一个具体示例和解决办法。

7813

被折叠的 条评论
为什么被折叠?



