TypeError:“ key”是此函数的无效关键字参数

时间:2019-05-02 10:09:38

标签: python opencv

我正在尝试使用opencv将图像转换为文本,但是代码给出了以下错误:

body: _loading
? Center(
   child: CircularProgressIndicator( //Show a Circular Progress indicator
     valueColor: new AlwaysStoppedAnimation<Color>(Colors.cyan),
    ),
  )
:Column(//Show your Dashboard)

有什么办法可以解决?这是代码:

contours.sort(key=lambda x: get_contour_precedence(x, img.shape[1]))
TypeError: 'key' is an invalid keyword argument for this function error.

1 个答案:

答案 0 :(得分:1)

您使用的sort()函数不带key参数。如果contours是可迭代的,则可以尝试使用sorted()来代替:

sorted(contours, key=lambda x:x)

请注意,这将返回一个列表。

相关问题