当前位置:   article > 正文

python遇到:TypeError: ‘int‘ object is not iterable和TypeError: only integer scalar arrays can be conver_typeerror: 'int' object is not iterable

typeerror: 'int' object is not iterable

运行python的时候遇到以下问题:

  1. TypeError: ‘int’ object is not iterable
  2. TypeError: only integer scalar arrays can be converted to a scalar index

我出问题的代码部分为:

for i in len(classes):
	img_3[i] = img_2
  • 1
  • 2

问题出在len(classes)上,它并不是一个可迭代对象
解决方法:整数对象本身不是可迭代的,将整数对象转换为可迭代对象,使用range函数

for i in range(len(classes)):
	img_3[i] = img_2
  • 1
  • 2
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/692402
推荐阅读
相关标签
  

闽ICP备14008679号