TypeError: string indices must be integers, not 'str'TypeError: string indices must be integers, not 'str'
时间: 2023-10-17 18:34:56 浏览: 83
这个错误意味着在代码中使用了字符串作为列表的索引,而不是整数。这通常是由于错误的访问列表元素引起的。你需要确保在使用索引时,只使用整数类型的值。可能的解决方法之一是检查你的代码中是否有使用字符串作为索引的地方,并将其更正为整数。你还可以使用`type()`函数来检查变量的类型,确保你使用的是正确的索引类型。另外,请确保你在访问列表元素时使用了正确的语法。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [Python:TypeError: list indices must be integers or slices, not str报错解决及原理](https://blog.csdn.net/hhd1988/article/details/128031602)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [Python解析json时提示“string indices must be integers”问题解决方法](https://download.csdn.net/download/weixin_38590784/13996149)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [Python BeautifulSoup [解决方法] TypeError: list indices must be integers or slices, not str](https://download.csdn.net/download/weixin_38590567/14871394)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]