Python3 适合初学者学习的银行账户登录系统实例
作者:jingxian 时间:2021-06-16 05:09:22
一、所用知识点:
1. for循环与if判断的结合
2. %s占位符的使用
3. 辅助标志的使用(标志位)
4. break的使用
二、代码示例:
'''
银行登录系统
'''
uname = "bob"
passwd = 123
judgment = 0
choice = 2
for i in range(3):
username = input("请输入用户名:")
password = int(input("请输入密码:"))
if username == uname and password == passwd: #用户名和密码必须同时成立
print("~~~欢迎%s使用银行自助服务系统~~~" %uname) # %s是占位符
judgment = 1
break
else:
if choice != 0:
print("!!!登陆失败!!!" + "您还有" + str(choice) + "次机会")
else:
print("!!!登陆失败!!!")
choice = choice - 1
if judgment == 0:
print("三次机会已用完,此卡将冻结10分钟") #只是提示信息,冻结操作并未编写
# 第二种思路
# uname = "bob"
# passwd = 123
#
# choice = 2
#
# for i in range(3):
# username = input("请输入用户名:")
# password = int(input("请输入密码:"))
# if username == uname and password == passwd:
# print("~~~欢迎%s使用银行自助服务系统~~~" %uname) # %s是占位符
#
# break
# else:
# if choice != 0:
# print("!!!登陆失败!!!" + "您还有" + str(choice) + "次机会")
# else:
# print("!!!登陆失败!!!")
# choice = choice - 1
# else:
# print("三次机会已用完,此卡将冻结10分钟")
#
#
标签:Python3,银行账户,登录
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
深入浅析Python中的yield关键字
2022-04-18 05:02:32
python实现用户名密码校验
2022-12-14 07:48:33
![](https://img.aspxhome.com/file/2023/4/70684_0s.jpg)
python实现银行管理系统
2021-07-09 00:33:49
JavaScript,5种调用函数的方法[译]
2009-02-24 16:26:00
pytorch-gpu安装的经验与教训
2022-01-11 20:23:36
![](https://img.aspxhome.com/file/2023/5/102805_0s.jpg)
优化次数过多的循环
2009-11-12 12:35:00
python实现windows下文件备份脚本
2021-05-06 06:32:41
使用Python脚本将绝对url替换为相对url的教程
2022-09-03 09:36:39
python实现AES加密与解密
2022-12-08 08:18:40
Python探索之修改Python搜索路径
2021-06-26 20:47:09
存储过程优缺点分析
2012-04-13 11:39:56
浅谈Python从全局与局部变量到装饰器的相关知识
2022-06-02 12:23:26
Python中eval()函数的详细使用教程
2023-11-22 15:51:39
![](https://img.aspxhome.com/file/2023/8/78578_0s.png)
Python实现树的先序、中序、后序排序算法示例
2022-12-26 04:00:18
python制作一个桌面便签软件
2021-02-23 05:20:40
pycharm中使用request和Pytest进行接口测试的方法
2022-06-30 03:34:46
![](https://img.aspxhome.com/file/2023/9/90599_0s.png)
oracle 日期函数集合(集中版本)第1/2页
2009-06-19 17:23:00
python记录程序运行时间的三种方法
2023-08-25 03:12:19
Python编程pytorch深度卷积神经网络AlexNet详解
2022-02-18 10:28:40
![](https://img.aspxhome.com/file/2023/5/105235_0s.png)
页面加载对访问的影响
2009-10-30 18:54:00
![](https://img.aspxhome.com/file/UploadPic/200910/30/speed_taobaoued-30s.png)