This article mainly introduces the differences between input and raw_input in Python. they are all used to read the input functions in the console. if you need them, you can refer to using both input and raw_input to read the input in the console, however, there is a difference between input and raw_input when processing numbers.
When the input is a pure number:
Input returns numeric values, such as int and float.
Raw_inpout returns the string type and the string type.
Input string as expression
Input calculates the number expression in the string, but raw_input does not.
For example, enter "57 + 3 ":
Input returns an integer of 60.
Raw_input will get the string "57 + 3"
Python input implementation
Read the python input document and you can see that the input is actually implemented through raw_input. The principle is very simple. the following code line is as follows:
The code is as follows:
Def input (prompt ):
Return (eval (raw_input (prompt )))