Python : TypeError: 'int' object is not iterable
用循环依次对list中的每个名字打印出 Hello, xxx!
--------------------------------------------------------
L = ['Bart', 'Lisa', 'Adam']
x = len(L)
for i in range(x):
print('Hello,', L[i])
--------------------------------------------------------
此处,若直接使用 for i in x 时,编译报错:TypeError: 'int' object is not iterable:
Traceback (most recent call last):
File "main.py", line 5, in <module>
for i in x:
TypeError: 'int' object is not iterable
该问题的原因是:不能直接用int进行迭代,而必须使用range方法,即range(x).
Python : TypeError: 'int' object is not iterable的更多相关文章
- python"TypeError: 'NoneType' object is not iterable"错误解析
尊重原创博主,原文链接:https://blog.csdn.net/dataspark/article/details/9953225 [解析] 一般是函数返回值为None,并被赋给了多个变量. 实例 ...
- python TypeError: 'int' object is not callable 问题解决
TypeError: 'int' object is not callable 这个错误的原因很简单 看下面的程序: def loss(a,b): return a-b loss = 0 loss = ...
- python TypeError: 'NoneType' object is not iterable
list(set(map(lambda tp_id : tp_id if not ('#' in tp_id) and len(tp_id.strip().replace('\n', '')) > ...
- TypeError: 'TestCase' object is not iterable
这个异常呢其实是因为我对list没有足够熟悉 我一开始很疑惑,明明已经正确返回testcase对象了呀,为啥会报TypeError: 'TestCase' object is not iterable ...
- for遍历用例数据时,报错:TypeError: list indices must be integers, not dict,'int' object is not iterable解决方法
一:报错:TypeError: list indices must be integers, not dict for i in range(0,len(test_data)): suite.addT ...
- python报错:TypeError: 'int' object is not subscriptable
检查一遍报错的所在行,此报错一般是在整数上加了下标: 比如: a = 4 c=a[2] 报错:line 2, in <module> c=a[2] TypeError: 'i ...
- python: "TypeError: 'type' object is not subscriptable"
目前stackoverflow找到两种情况的解决办法: 1.TypeError: 'type' object is not subscriptable when indexing in to a di ...
- TypeError: 'ExcelData' object is not iterable
今天写了个测试的代码,结果在执行test_register.py文件在调用readexcle.py的时候一直报错TypeError: 'ExcelData' object is not iterabl ...
- Debug 路漫漫-11:Python: TypeError: 'generator' object is not subscriptable
调试程序,出现以下错误: Python: TypeError: 'generator' object is not subscriptable “在Python中,这种一边循环一边计算的机制,称为生成 ...
随机推荐
- 在VS工程中,添加c/c++工程中外部头文件(.h),lib库,dll库的基本步骤
选择工程,右键-工程属性 其中: VC++目录 -->包含目录,对所有的项目及未来新建的项目都有效 c/c++-->常规-->附加包含目录,仅对当前项目有效 绝对路径设置方法: 在V ...
- Contos6.5卸载自带JDK
1.查看CentOS6.5自带的JDK是否已经安装#Java -version2.查看JDK的信息#rpm -qa|grep java3.卸载JDK#rpm -e --nodeps tzdata-ja ...
- HTML基本语法(慕课网学习笔记)
标题 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8& ...
- springcloud <zuul2.0静态配置>
server: port: 9006 spring: application: name: cloud-zuul-wangbiao # zipkin: # base-url: http://local ...
- vue3.0入门(三)
前言 最近在b站上学习了飞哥的vue教程 学习案例已上传,下载地址 class绑定 对象绑定 :class='{active:isActive}' // 相当于class="active&q ...
- 2020最精细的Java学习路线图
在吾爱破解发布的Java学习路线图自我感觉良好,之后看到动力节点Java学院的这份学习路线图感觉专业的东西还得专业的人来做,这份专业的学路线图把我上次的Java学习路线图秒成渣,虽然内容差不多,上份是 ...
- roscore启动不完全问题
运行roscore,得到如下日志,且一直卡着无法继续执行 ... logging to /home/xbit/.ros/log/79f2952c-589c-11ea-8213-d0abd5e7d222 ...
- 在已有Win7/10系统电脑中加装Ubuntu18.04(安装双系统)
准备一台有Win7/10的电脑. 为Ubuntu预留硬盘空间.最好在硬盘最后保留一个空闲分区.(Ubuntu会自动安装到后面的空闲分区) 用Universal USB Installer制作安装盘(U ...
- 使用HttpRunner3+Allure+Jenkins实现Web接口自动化测试
陆续给不同项目做了Web接口自动化测试,在尝试不同方法的同时会有新的体会.最近用到了HttpRunner3,本文将记录使用HttpRunner3+Allure+Jenkins在项目中快速实现Web接口 ...
- QT程序打包成多平台可执行文件
一.简述 QT项目开发完成后,需要打包发布程序,在实际生产中不可能把源码发给别人,所以需要将源码打包正可执行文件或者安装程序. 二.设置应用图标 把 ico 文件放到源代码目录下,在QT项目中的'.p ...