想要通过索引来迭代一个list或者string的元素, 这需要调用 range() 函数.要记得返回len 值而不是返回这个列表.…
ImportError: cannot import name 'izip' 参考:https://codereview.stackexchange.com/questions/26271/import-izip-for-different-versions-of-python A common idiom that I use for Python2-Python3 compatibility is: gedit mtcnn_detector.py try: from itertools im…
TypeError: 'list' object cannot be interpreted as an integer 类型错误,不能将list对象转换为一个整数. 错误代码,例如如下例子: args = [3,6] print(list(range(args))) range函数本应该需求,一个整数,或者一对范围,或者三个整数类型,才能构造一个iterable,这里直接将args这个列表传递给它是不行的,需要通过解压缩机制,更正后代码为: args = [3,6] print(list(ra…
Q: for i in range(len(shape)/2):TypeError: 'float' object cannot be interpreted as an integer A: for i in range(len(shape)//2): 参考 1. https://blog.csdn.net/weixin_39223665/article/details/79485643; 完…
1.string是一种不可变的数据类型 2.尝试使用 range()创建整数列 有时你想要得到一个有序的整数列表,所以 range() 看上去是生成此列表的不错方式. 需要记住 range() 返回的是 "range object",而不是实际的 list 值…
尝试连接非字符串值与字符串 想要字符串连接非字符串需要先进行强制转化 可以用str()函数 --------------------------------…
方法名拼写错误 检查方法名拼写,如有错误改正即可 特别注意m和n…
  忘记为方法的第一个参数添加self参数 ---------------------------------------------------------------…
程序代码  class Person:      #constructor      def __init__(self,name,sex):           self.Name = name           self.Sex = sex      def ToString(self):           return 'Name:'+self.Name+',Sex:'+self.Sex 在IDLE中报错: >>> import Person >>> per…
问题:  TypeError: 'dict' object is not callable 原因:  dict()是python的一个内建函数,如果将dict自定义为一个python字典,在之后想调用dict()函数是会报出“TypeError: 'dict' object is not callable”的错误, 解决办法:  >>>del (dict)…