报错url()+take+0+positional+arguments+but+2+were+given
时间: 2024-01-09 14:23:12 浏览: 157
根据您提供的引用内容,报错"TypeError: imwrite() takes 2 positional arguments but 3 were given"是因为cv2.imwrite()方法只接受两个位置参数,而您传递了三个参数。这可能是由于您在第三个参数中使用了方括号的方式来传递参数。正确的写法是将第三个参数作为关键字参数传递给cv2.imwrite()方法。
以下是一个示例,展示了如何正确使用cv2.imwrite()方法保存png图片:
```python
import cv2
imgPath = "image.png"
tempRectImg = cv2.imread("temp_rect_image.jpg")
cv2.imwrite(imgPath, tempRectImg, params=[int(cv2.IMWRITE_PNG_COMPRESSION), 0])
```
在这个示例中,我们将第三个参数`[int(cv2.IMWRITE_PNG_COMPRESSION), 0]`作为关键字参数`params`传递给cv2.imwrite()方法。
相关问题
TypeError: verify() takes 2 positional arguments but 685 were given
This error message likely means that you are passing too many arguments to a function called "verify". The function is designed to take two arguments, but you are passing it 685 arguments.
To fix the error, you will need to review the code that calls the "verify" function and make sure that you are only passing in the correct number of arguments. If you are unsure where the error is occurring, you can use print statements or a debugger to help you identify the issue.
TypeError: Triangle() takes 0 positional arguments but 3 were given
This error message occurs when you try to call the Triangle() function with three arguments, but the function is defined to take zero arguments.
To fix this error, you need to either modify the Triangle() function to accept three arguments or pass zero arguments when calling the function.
阅读全文