网页学习体会

  • 首页
  • 个人博客
您的位置: 首页  >  技术问答  >  Python报错list indices must be integers, not str

Python报错list indices must be integers, not str

分类: 技术问答 • 2022-03-05 12:02:23

Python报错list indices must be integers, not str

问题描述:

![图片说明](https://img-ask.****.net/upload/201504/21/1429590203_490074.png)图片说明
分别是代码和报错,求大神们指点一二

答

若是corterm是整数字符串,则把tfidf[corterm]改为tfidf[int(corterm)]即可。

答

错误解释很清楚:你的列表的索引必须是int类型不能为str。
并且按照尝试,数组的下标一般都是整型的。

答

corterm要为int类型,不能是字符串

相关推荐

  • python报错 TypeError: string indices must be integers
  • Python: list indices must be integers or slices, not float问题
  • Python TypeError: can only concatenate str (not "list") to str 报错问题的解决
  • requests+unittest接口自动化之报错:TypeError: list indices must be integers or slices, not str
  • python报错:TypeError: slice indices must be integers or None or have an __index__ method
  • requests返回.text类型形似dict,索引后报错“TypeError:string indices must be integers”
  • 解决Python中报错TypeError: must be str, not bytes问题
  • Python解析json时提示“string indices must be integers”问题解决方法
  • TypeError: list indices must be integers or slices, not tuple
  • TypeError: string indices must be integers, not str
  • idea2019的pulgins中查找不到插件
  • 无法使用golang读取csv文件中的json str
    网站免责声明 网站地图 最新文章 用户隐私 版权申明
本站所有数据收集于网络,如果侵犯到您的权益,请联系网站进行下架处理。   

Copyright © 2018-2021   Powered By 网页学习体会    备案号:   粤ICP备20002247号