kernel.raw_input() takes from 1 to 2 positional arguments but 3 were given
时间: 2023-09-22 16:07:48 浏览: 376
这个错误是因为在调用 `kernel.raw_input()` 函数时,传入了 3 个参数,而该函数只接受 1 到 2 个参数。
`kernel.raw_input()` 函数是 Jupyter Notebook 中用于交互式输入的函数,其用法与 Python 内置的 `input()` 函数类似。你可以使用以下代码示例进行输入:
```
input_str = input("请输入两个数,以空格分隔:")
a, b = input_str.split()
```
这将提示用户输入两个数,以空格分隔,然后将这两个数分别存储在变量 a 和 b 中。
如果你仍然遇到问题,请提供更具体的代码,以便我能够更好地帮助你。
相关问题
raw_input() takes from 1 to 2 positional arguments but 3 were given
This error message indicates that the function raw_input() was called with three arguments, but it only accepts one or two arguments.
The most common cause of this error is passing too many arguments to the function. For example, if you try to call raw_input() with three strings as arguments, like this:
raw_input("Enter your name: ", "Enter your age: ", "Enter your gender: ")
You will get the "takes from 1 to 2 positional arguments but 3 were given" error message, because raw_input() only accepts one or two arguments.
To fix this error, you need to pass the correct number of arguments to the function. In the case of raw_input(), you should only pass one argument if you want to display a prompt message, like this:
name = raw_input("Enter your name: ")
Or you can call the function without any arguments, like this:
name = raw_input()
DBSCAN.__init__() takes from 1 to 2 positional arguments but 3 were given
This error message indicates that you are passing three positional arguments to the `__init__()` method of the `DBSCAN` class, but it is designed to take only one or two positional arguments.
To fix this error, you should check the number of arguments you are passing to the `DBSCAN` constructor and make sure that it matches the number of arguments that the constructor expects. Alternatively, you may need to modify the `DBSCAN` class to accept the additional argument that you are passing.
阅读全文