当前位置:网站首页>登录程序2
登录程序2
2022-04-21 15:28:00 【右耳要加油】
count={
}
f=open("账号密码本.txt",mode="r",encoding="utf_8")
for line in f:
line=line.strip().split(",")
# print(line)
# 字典的增添
count[line[0]]=line
print(count)
while True:
user=input("请输入账号:").strip()
if user not in count:
print("该账号未注册")
continue
elif count[user][2]=="0":
print("该账号已被锁定")
continue
num=0
while num<3:
password=input("请输入密码:").strip()
if count[user][1]==password:
print(f"欢迎{user}使用")
exit("bey....")
else:
print(f"请再次输入密码,你还有{2-num}次机会")
num+=1
if num==3:
print(f"密码输入次数{num},已被锁定")
count[user][2]="0"
f2=open("账号密码本.txt",mode="w",encoding="utf_8")
for p,v in count.items(): # 裴家奇['裴家奇', '111', '0']裴坚强['裴坚强', '222', '0']
kk=",".join(v)+"\n"
f2.write(kk)#裴坚强,222,0裴家奇,111,0
f2.close()
break
代码思考:在存储文件中,用0/1数字判断账号是否锁定。若已经锁定则不进行下面判断。该账号三次密码输入错误,则修改0变为1,利用f.write()直接把源文件覆盖。也是可以利用os函数,直接操作文件对文件进行修改。
版权声明
本文为[右耳要加油]所创,转载请带上原文链接,感谢
https://blog.csdn.net/m0_59882269/article/details/124266018
边栏推荐
- SQL服务器如何设置起始日期查询语句
- 49页石油石化行业信息化规划与数字化转型
- Smart public security QR code positioning alarm system development of mobile police app
- 111 page data word transformation solution of Fine Chemical Co., Ltd
- SMTP协议解读以及如何使用SMTP协议发送电子邮件
- 【unity笔记】L3Unity Shader学习开始
- AcWing1800. Do not do the last (enumeration)
- 嵌入式驱动模块的加载与卸载
- 102页新一代数字化转型信息化总体规划方案
- 什么是电子邮件的格式?企业邮箱地址是什么?
猜你喜欢

手把手教你实现手绘风格图形

Simple explanation of impermanence loss

What exactly does the distributed core principle analysis that fascinates Alibaba P8? I was surprised after reading it

Reading breaks ten thousand "volumes": National Reading insight 2022

AcWing 1866. Fence painting (section crossing)

AcWing 1788. 牛为什么过马路(模拟)

嵌入式驱动模块的加载与卸载

【unity笔记】L3Unity Shader学习开始

Detailed explanation of basic knowledge of database 5: index and its two engines in mysql, master-slave replication and relational / non relational database

Site intelligent solution
随机推荐
Applet introduction and development tools
Plug in development practice of a simple annotation Library
跟着中富金石学炒股,25年行业沉淀,投资要用实力说话
外贸公司一般用什么邮箱,电子邮件如何群发?
Mysql
手把手教你实现手绘风格图形
红队技术-父进程伪装(MITRE ATT&CK框架:T1134)
Winter is coming. Let's snow your website
企业邮箱如何申请?如何用手机号注册邮箱?
【二分查找-简单】278. 第一个错误的版本
AcWing 1866. Fence painting (section crossing)
【unity笔记】L2Unity Shader基础
【二分查找-简单】69. x 的平方根
What conditions need to be met for an app to go online in the app store?
AcWing 1854. 晋升计数(模拟)
Dry goods | app control positioning of mobile app automation
[binary search - medium] 1855 Maximum distance of subscript alignment (need to review double pointer method)
智慧园区数融通-数字化赋能运营管理平台解决方案
返璞归真,多方安全计算要回归到“安全”的本源考虑
[unity note] l3unity shader learning begins