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     “\n"要是字符串类型才能换行!
13      字符串和变量之间必须有拼接  +  号!
14      拼接还要前后类型一致才可以,必须都是str
15     """
16     print("Your username is:" + a +'\n' + "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 +'\n' + "Your password is:"+ b)
20 else:
21     print("User login failed!" + '\n' + "Your username is:" + a +'\n' + "Your password is:"+ b)

 

posted @ 2017-11-23 18:30  俊豪郎  阅读(446)  评论(0编辑  收藏  举报