Input, output
How does python receive user input, use the input function, use Raw_input in Python2, receive a string, output, the first program has been written using print, code into the following:
1 2 |
Name=input (' Please enter your name: ') #把接收到的值赋给name变量 Print (name) #输出接收到的输入 |
Input at the time of receiving inputs, you can see the value you entered, if you enter a password like this, do not want to let others see your password, how to do it, you need to use a standard library, Getpass, what is the standard library, is not need you to install, loaded Python on the library, is the standard library, Getpass is a standard library, import in, directly using the Getpass.getpass method can be entered at the time, do not echo, the code is as follows:
1 2 3 |
Import Getpass #导入getpass模块 Password = getpass.getpass (' Please enter your password: ') #接收输入的密码 Print (password) |
# Input/Output
# name=input (' Please enter your name: ') # Enter username
# print (name)
# Enter the password, the password is not visible
Import getpass # Importing a module
passwd=getpass.getpass (" Please enter your password")
Print (passwd)# Note: Getpass cannot be executed in Pytcharm
Python Note 3-output input