012Python and user interaction

Python and user interaction


First, why interaction

Let's review what is the significance of computers invention, invention of the computer to computer slavery, the liberation of labor. Suppose we now write an ATM system replaces teller, if we want to withdraw money from this ATM, the ATM is not so that we will be asked to enter your name and password? We are not required to enter the withdrawal amount we need? This is not to be understood as an interaction. Let us now understand how to achieve the next Python is interactive.

Second, how to interact with (how to mutual)

>>> print('-'*80)
>>> input("请输入你的姓名:")
>>> print('*'*80)
----------------------------------------------------------------------
请输入你的姓名:FirstReed
**********************************************************************

ATM landing system? ? ?

>>> name = input('请输入你的姓名:')
>>> pwd = input('请输入你的密码:')
>>> print(type(name))
>>> print(type(pwd))
请输入你的姓名:reed
请输入你的密码:123
<class 'str'>
<class 'str'>

By printing the above results, we can find action input () method is only received values. As we currently lack the basics, we do use the input () interaction, then use the Web / visual form of interactive interface.

Guess you like

Origin www.cnblogs.com/FirstReed/p/11729799.html