One, the password input does not display
Method: Getpass
Import Getpass
Username = input ("Username:")
Password = getpass.getpass ("Password:")
Print (Username,password)
Result output:
[[Email protected]~]#./hello.py
Username:user
Password
(' user ', ' 123 ')
[[Email protected]~]#
Second, if judgment
#Author: Robinwen
_username = "Robin"
_password = "123456"
Username = input ("Username:")
Password = input ("Password:")
If_username = = Username and _password = = password:
Print ("Welcome User {name} logo in!". Format (name=username))
Else
Print ("Invalid username or password!")
Result output:
(1) True
Username:robin
password:123456
Welcome User Robin logo in!
(2) False
Username:robin
password:111
Invalid Username or password!
Three, age guessing-if judgment
#Author: Robinwen
My_age=25
guess_age = Int (Input ("Age:"))
if guess_age = = My_age:
Print ("Yes,you got It!")
Elif guess_age > My_age:
Print ("Bigger ...")
Else
Print ("smaller ...")
Python-if Else process judgment--006