设为首页 加入收藏

TOP

Python3 适合初学者学习的银行账户登录系统
2017-09-30 17:03:32 】 浏览:9909
Tags:Python3 适合 学者 学习 银行 账户 登录 系统

一、所用知识点:

  1. for循环与if判断的结合

  2. %s占位符的使用

  3. 辅助标志的使用(标志位)

  4. break的使用

二、代码示例:

 1 '''
 2 银行登录系统
 3 '''
 4 
 5 uname = "bob"
 6 passwd = 123
 7 judgment = 0
 8 choice = 2
 9 
10 for i in range(3):
11     username = input("请输入用户名:")
12     password = int(input("请输入密码:"))
13     if username == uname and password == passwd:    #用户名和密码必须同时成立
14         print("~~~欢迎%s使用银行自助服务系统~~~" %uname)    # %s是占位符
15         judgment = 1
16         break
17     else:
18         if choice != 0:
19             print("!!!登陆失败!!!" + "您还有" + str(choice) + "次机会")
20         else:
21             print("!!!登陆失败!!!")
22         choice = choice - 1
23 if judgment == 0:
24         print("三次机会已用完,此卡将冻结10分钟")  #只是提示信息,冻结操作并未编写
25 
26 
27 
28 # 第二种思路
29 # uname = "bob"
30 # passwd = 123
31 #
32 # choice = 2
33 #
34 # for i in range(3):
35 #     username = input("请输入用户名:")
36 #     password = int(input("请输入密码:"))
37 #     if username == uname and password == passwd:
38 #         print("~~~欢迎%s使用银行自助服务系统~~~" %uname)    # %s是占位符
39 #
40 #         break
41 #     else:
42 #         if choice != 0:
43 #             print("!!!登陆失败!!!" + "您还有" + str(choice) + "次机会")
44 #         else:
45 #             print("!!!登陆失败!!!")
46 #         choice = choice - 1
47 # else:
48 #     print("三次机会已用完,此卡将冻结10分钟")
49 # 
50 #

 

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Python爬虫之xlml解析库 下一篇python 学习之路

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目