python:TypeError: ‘int‘ object is not iterable
我在进行for循环的时候,报错TypeError: ‘int’ object is not iterable
原因:
误将int变量当作list变量使用
解决方法:
使用range()方法进行迭代。
注:int变量即迭代的次数,应使用range(),而list变量,则不需要。可直接迭代循环
for num in nums:
...
原创
2021-04-10 17:18:14 ·
516 阅读 ·
0 评论