您的位置: 首页 > 技术问答 > Python报错list indices must be integers, not str Python报错list indices must be integers, not str 分类: 技术问答 • 2022-03-05 12:02:23 问题描述: 分别是代码和报错,求大神们指点一二 答 若是corterm是整数字符串,则把tfidf[corterm]改为tfidf[int(corterm)]即可。 答 错误解释很清楚:你的列表的索引必须是int类型不能为str。 并且按照尝试,数组的下标一般都是整型的。 答 corterm要为int类型,不能是字符串