想要通过索引来迭代一个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. Python 2 to Python 3 convert

    Python 2 to Python 3 convert 2to3, 自动将 Python 2 代码转为 Python 3 代码 https://docs.python.org/zh-cn/2/lib ...

  2. component & slot

    component & slot <template> <div class="myHeaderContainer"> <header cla ...

  3. web 语音播报 & 网页阅读器

    web 语音播报 & 网页阅读器 Chrome auto speech & voice speaking http://3.141592653589793238462643383279 ...

  4. vuex bug & vue computed setter

    vuex bug & vue computed setter https://vuejs.org/v2/guide/computed.html#Computed-Setter [Vue war ...

  5. ts 索引签名 无视多余的属性类型

    interface SquareConfig { color?: string; width?: number; [propName: string]: any; } function asd(opt ...

  6. Flutter 区分开发环境和生产环境

    Uri _baseUrl; final isProd = const bool.fromEnvironment('dart.vm.product'); if (isProd) { _baseUrl = ...

  7. spring-ioc心得

    1.创建spring容器,严格的来说就是创建ClassPathXmlApplicationContext对象, 该对象属于ApplicationContext类型(是一个接口)该接口下有很多实现类, ...

  8. mybatis 一对多和多对一 简单案例笔记

    以案例说明(以下案例代码都敲过验证过) 多对一(多个学生对一个老师  即学生集合中都存一个老师对象) Mybatis多对一实现方式1: //定义Student 和 Teacher 实体 @Data p ...

  9. SpringBoot读取资源目录下的文件

    需要读取resources目录下的文件,那么方法如下: 假设在资源目录下的template目录下有一个文件a.txt,获取到文件流的方式 InputStream stream = this.getCl ...

  10. Docker 镜像加速教程

    原文链接:https://fuckcloudnative.io/posts/docker-registry-proxy/ 在使用 Docker 和 Kubernetes 时,我们经常需要访问 gcr. ...