1 _username = 'leon' 2 _password = 'zyl' 3 username = input("username:") 4 password = input("password:") 5 if _username == username and _password == password: 6 print("welcome user {name} login ... ".format(name=username)) 7 else: 8 print("Invalid username or password!")
打印结果:
当输入正确的用户名密码时:
1 C:\Python36\python.exe H:/leon/day1/input.py 2 username:leon 3 password:zyl 4 welcome user leon login ... 5 6 Process finished with exit code 0
当输入错误的用户名密码时:
1 C:\Python36\python.exe H:/leon/day1/input.py 2 username:ll 3 password:tt 4 Invalid username or password! 5 6 Process finished with exit code 0