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

 1 #!/usr/bin/env python
 2 # -*- coding: utf-8 -*-
 3 #模拟简单用户登录(自写)
 4 import getpass
 5 a = raw_input("Please enter the username:")
 6 b = getpass.getpass("Please enter your password:")
 7 user = "admin"
 8 pwd = "admin"
 9 if a == "wangshaohan" and b =="admin888":
10     print("Ordinary user login successfully!")
11     """
12     “
"要是字符串类型才能换行!
13      字符串和变量之间必须有拼接  +  号!
14      拼接还要前后类型一致才可以,必须都是str
15     """
16     print("Your username is:" + a +'
' + "Your password is:"+ b)
17 elif user == a == "admin" and pwd == b == "admin":
18     print("Administrator user logged in successfully!")
19     print("Your username is:" + a +'
' + "Your password is:"+ b)
20 else:
21     print("User login failed!" + '
' + "Your username is:" + a +'
' + "Your password is:"+ b)
作者:俊豪郎
出处:http://www.cnblogs.com/shaohan/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。
原文地址:https://www.cnblogs.com/shaohan/p/7886382.html