python入门:模拟简单用户登录(自写)

时间:2023-03-08 16:14:50
python入门:模拟简单用户登录(自写)
 #!/usr/bin/env python
# -*- coding: utf-8 -*-
#模拟简单用户登录(自写)
import getpass
a = raw_input("Please enter the username:")
b = getpass.getpass("Please enter your password:")
user = "admin"
pwd = "admin"
if a == "wangshaohan" and b =="admin888":
print("Ordinary user login successfully!")
"""
“\n"要是字符串类型才能换行!
字符串和变量之间必须有拼接 + 号!
拼接还要前后类型一致才可以,必须都是str
"""
print("Your username is:" + a +'\n' + "Your password is:"+ b)
elif user == a == "admin" and pwd == b == "admin":
print("Administrator user logged in successfully!")
print("Your username is:" + a +'\n' + "Your password is:"+ b)
else:
print("User login failed!" + '\n' + "Your username is:" + a +'\n' + "Your password is:"+ b)