开发者社区 问答 正文

Python报错list indices must be integers, n?报错

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

展开
收起
爱吃鱼的程序员 2020-06-24 14:06:39 449 分享 版权
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

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

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

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

    2020-06-24 14:06:54
    赞同 展开评论