Home >Backend Development >Python Tutorial >What is input in python
The input() function in Python3.x accepts a standard input data and returns it as string type.
In Python2.x, input() is equivalent to eval(raw_input(prompt)), which is used to obtain console input.
raw_input() treats all input as strings and returns the string type. And input() has its own characteristics when dealing with pure numeric input. It returns the type of the entered number (int, float).
Note: Both input() and raw_input() functions can receive strings, but raw_input() directly reads the input from the console (any type of input can be take over). As for input(), it hopes to be able to read a legal python expression, that is, you must use quotes to enclose it when you enter a string, otherwise it will raise a SyntaxError.
Unless there is a special need for input(), we generally recommend using raw_input() to interact with users.
Note: input() in python3 receives the str type by default.
The following example runs in the python3 version
Enter two numbers
or
The above is the detailed content of What is input in python. For more information, please follow other related articles on the PHP Chinese website!