giaming 2022-10-21 14:15 采纳率: 33.3%
浏览 64
已结题

python中使用len()函数报错TypeError: 'float' object is not callable

python中使用len()函数报错TypeError: 'float' object is not callable

def drawShape(src,points):
i=0
while i< len(points) :
if (i==len(points)-1):
x,y=points[i][0] #points是三层的结构
x1,y1=points[0][0]
cv2.lines(src,(x,y),(x1,y1),(0,0,255),1)
else:
x,y=points[i][0] #points是三层的结构
x1,y1=points[i+1][0]
cv2.lines(src,(x,y),(x1,y1),(0,0,255),1)
i=i+1
contours,hierarchy=cv2.findContours(binary,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
print(contours)
e=20
approx=cv2.approxPolyDP(contours[15],e,True)
drawShape(img,approx)
cv2.imshow('img',img)
cv2.waitKey(0)

TypeError Traceback (most recent call last)
-> 3 while i< len(points) :
4 if (i==len(points)-1):
5 x,y=points[i][0] #points是三层的结构
TypeError: 'float' object is not callable

TypeError: 'float' object is not callable

  • 写回答

3条回答 默认 最新

  • 於黾 2022-10-21 14:42
    关注

    'float' object is not callable
    出现这种错误提示,表示你把一个float型当函数在调用
    你是不是有个变量起名叫len了
    查找所有引用,看到底在哪定义的

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 10月29日
  • 已采纳回答 10月21日
  • 修改了问题 10月21日
  • 创建了问题 10月21日

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改