10 月 092020
#条件控制
#如果……条件是成立的,就做……,反之,就做……
#定义一个函数
def account_login():
password = input('Password:') #将用户输入赋值给变量
password_correct = password == '12345' #将密码布尔运算结果赋值给变量
if password_correct: #如果条件成立
print('Login success!')
else: #反之,打印错误提示信息并再次调用函数
print('Wrong password or invalid input!')
account_login()
#调用函数
account_login()
PS C:\Users\harveymei> & C:/Users/harveymei/AppData/Local/Programs/Python/Python39/python.exe c:/Users/harveymei/hello.py
Password:54321
Wrong password or invalid input!
Password:12345
Login success!
PS C:\Users\harveymei>