raw_input() takes from 1 to 2 positional arguments but 3 were given
时间: 2023-10-31 08:35:33 浏览: 265
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()
阅读全文