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

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-17
  • 2021-11-21
  • 2021-08-26
  • 2021-11-01
猜你喜欢
  • 2021-08-15
  • 2021-09-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案