TypeError: __init__() got multiple values for argument 'options'
时间: 2023-08-01 07:12:07 浏览: 897
这个错误通常是因为在创建 WebDriver 对象时,同时传递了多个参数给 `options` 。请确保你只传递了一个参数给 `options`。
这里是一个示例代码:
```python
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument("--headless") # 设置无头模式
driver = webdriver.Chrome(options=options)
```
请检查你的代码,确保没有其他地方重复传递了 `options` 参数给 `webdriver.Chrome()` 函数。如果仍然遇到问题,请提供更多的代码细节,以便我能更好地帮助你解决问题。
相关问题
TypeError: __init__() got multiple values for argument 'filters'
This error occurs when the `__init__()` method of a class is called with multiple values for the same argument.
For example, if you have a class `MyClass` with an `__init__()` method that takes a `filters` argument:
```
class MyClass:
def __init__(self, filters):
self.filters = filters
```
And you create an instance of this class and pass multiple values for `filters`:
```
my_instance = MyClass(filters='value1', filters='value2')
```
You will get the `TypeError: __init__() got multiple values for argument 'filters'` error.
To fix this error, make sure that you are only passing one value for each argument in the `__init__()` method. In the above example, you could pass a list of values for `filters` instead:
```
my_instance = MyClass(filters=['value1', 'value2'])
```
TypeError: __init__() got multiple values for argument 'strides'
This error occurs when you pass multiple values for the same argument in the initialization of an object or function.
For example, if you have a class that takes in a 'strides' argument in its __init__() method and you pass multiple values for 'strides' like this:
```
class MyClass:
def __init__(self, strides):
self.strides = strides
my_object = MyClass(strides=2, strides=3)
```
You will get the TypeError: __init__() got multiple values for argument 'strides'
To fix this error, make sure you are passing only one value for each argument. In the example above, you can fix the error by passing only one value for 'strides':
```
my_object = MyClass(strides=2)
```