我在进行for循环的时候,报错TypeError: ‘int’ object is not iterable
原因:
误将int变量当作list变量使用
解决方法:
使用range()方法进行迭代。
注:int变量即迭代的次数,应使用range(),而list变量,则不需要。可直接迭代循环
for num in nums:
python:TypeError: ‘int‘ object is not iterable
最新推荐文章于 2024-07-23 19:58:15 发布
我在进行for循环的时候,报错TypeError: ‘int’ object is not iterable
原因:
误将int变量当作list变量使用
解决方法:
使用range()方法进行迭代。
注:int变量即迭代的次数,应使用range(),而list变量,则不需要。可直接迭代循环
for num in nums: