Input is a built-in function:
|
>>> input
<built-in function input>
>>> |
?
Specific usage: Receives the user input the content, the input string, receives is the string, the input is the number, receives is the number
|
>>> name = input ("Please input your name:")
Please input your name:like
>>> Name
' Like '
>>> Print (name)
Like
>>> |
?
Eval usage: You can receive previously defined variables, in combination with input
|
>>> eval (' name ')
' LK '
>>> eval (Input ("Please input your Name:"))
Please input your name:name
' LK ' |
?
If you enter a variable that was not previously defined, you will be prompted with an error:
|
>>> eval (Input ("Please input your Name:"))
Please input your name:lk
Traceback (most recent):
File "<stdin>", line 1, in <module>
File "<string>", line 1, in <module>
Nameerror:name ' like ' isn't defined
>>> A = 5
>>> eval (Input ("Please input your Name:"))
Please input your name:a
5 |
Python Basic two user interaction input