Getpass module
When entering a password, if you want to be invisible, you need to use the getpass method in the getpass module.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import getpass
username = input("username: ")
password = getpass.getpass("password:")
print(username ,password)
This is not good in pyCharm, it is recommended to use in non-pyCharm
If judge
Take the login user to the password as an example, you must first save the password.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import getpass
_username = 'alex'
_password = "abc12"
username = input("username: ")
password = getpass.getpass("password:")
print(username ,password)
If both of them are equal, the login is successful.
if _username == username and _password == password:
print("Welcome user {name} login...".format(name=username))
Otherwise, the user password specification is not met.
if _username == username and _password == password:
print("Welcome user {name} login...".format(name=username))
else:
print("Invalid username or password!")