想要通过索引来迭代一个list或者string的元素,
这需要调用 range() 函数。要记得返回len 值而不是返回这个列表。

TypeError: 'list' object cannot be interpreted as an integer Python常见错误的更多相关文章

  1. ImportError: cannot import name 'izip & TypeError: 'float' object cannot be interpreted as an integer

    ImportError: cannot import name 'izip' 参考:https://codereview.stackexchange.com/questions/26271/impor ...

  2. TypeError: 'list' object cannot be interpreted as an integer

    TypeError: 'list' object cannot be interpreted as an integer 类型错误,不能将list对象转换为一个整数. 错误代码,例如如下例子: arg ...

  3. 【error】 for i in range(len(shape)/2): TypeError: 'float' object cannot be interpreted as an integer

    Q: for i in range(len(shape)/2):TypeError: 'float' object cannot be interpreted as an integer A: for ...

  4. TypeError: 'str' object does not support item assignment Python常见错误

    1.string是一种不可变的数据类型 2.尝试使用 range()创建整数列 有时你想要得到一个有序的整数列表,所以 range() 看上去是生成此列表的不错方式. 需要记住 range() 返回的 ...

  5. TypeError: Can't convert 'int' object to str implicitly Python常见错误

    尝试连接非字符串值与字符串 想要字符串连接非字符串需要先进行强制转化 可以用str()函数 --------------------------------

  6. AttributeError: 'str' object has no attribute 'lowerr' Python常见错误

    方法名拼写错误 检查方法名拼写,如有错误改正即可 特别注意m和n

  7. TypeError: myMethod() takes no arguments (1 given) Python常见错误

      忘记为方法的第一个参数添加self参数 ---------------------------------------------------------------

  8. TypeError: 'module' object is not callable cp fromhttp://blog.csdn.net/huang9012/article/details/17417133

    程序代码  class Person:      #constructor      def __init__(self,name,sex):           self.Name = name   ...

  9. Python: TypeError: 'dict' object is not callable

    问题:  TypeError: 'dict' object is not callable 原因:  dict()是python的一个内建函数,如果将dict自定义为一个python字典,在之后想调用 ...

随机推荐

  1. styled-components all in one

    styled-components all in one CSS in JS https://www.styled-components.com/ https://github.com/styled- ...

  2. SPC算力空投来袭!对话NGK!华盛顿金融特别报道

    近日华盛顿金融时报联合波士顿商业报等多家知名金融媒体专访了NGK. NGK代表马特彼得森就表示NGK在新的一年里将会继续以生态建设者为中心,以打造高倍币孵化器为目标,不断推进NGK项目的落地,踏踏实实 ...

  3. 多种转弯角度的PBN旁切转弯图例分析

    无论世界怎样变化,我们依然是有点阳光就灿烂.面对世界的未知,最好的状态是勇敢的去面对,努力的去生活. 今天我们继续来聊一下PBN旁切转弯. PBN转弯保护区的结构通常都与它们的转弯角度大小有关,转弯角 ...

  4. 发布Jar包到maven中央仓库

    什么是maven中央仓库 maven是java世界最流行的构建工具,构建内容囊括了一个java项目的整个生命周期.其中最重要的功能就是依赖管理,maven通过一个类似云的ftp站点统一管理所有java ...

  5. net里面using的使用

    起初using就明白一个作用  那就是引用命名空间.当面试官听到我回答这个问题的时候,马上就还问我,还有什么作用?我就只能摇头了,今天在网上看了下using的作用. 1.using指令.using + ...

  6. IDEA重新安装之后配置GIT

    注:此方法可用于配置gitlab也可用于配置github 1.在github中创建一个账号:https://github.com/join?source=header-home 2.下载并安装git: ...

  7. 【Android笔记】Thread类中关于join()方法的源码分析

    1.join()方法的作用: 例如有一个线程对象为Thread1,在main()方法中调用Thread1.join()方法可使得当前线程(即主线程)阻塞,而执行Thread1线程. 2.源码分析(以上 ...

  8. HDOJ-3065(AC自动机+每个模板串的出现次数)

    病毒侵袭持续中 HDOJ-3065 第一个需要注意的是树节点的个数也就是tree的第一维需要的空间是多少:模板串的个数*最长模板串的长度 一开始我的答案总时WA,原因是我的方法一开始不是这样做的,我是 ...

  9. SpringBoot启动流程原理解析(二)

    在上一章我们分析了SpingBoot启动流程中实例化SpingApplication的过程. return new SpringApplication(primarySources).run(args ...

  10. ThinkAdmin v6 未授权列目录/任意文件读取复现

    大佬的审计文章:https://github.com/zoujingli/ThinkAdmin/issues/244 任意文件读取 POC curl http://127.0.0.1/admin.ht ...