博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
先注册,再登录(简易版)
阅读量:4709 次
发布时间:2019-06-10

本文共 627 字,大约阅读时间需要 2 分钟。

先注册,将用户名和密码写入文件,然后三次机会登录,将文件中的信息读出与输入的信息比较

#换行符  \n   

#s.strip()   除去字符串两端的空格或换行符

username = input('请输入你要注册的用户名:')password = input('请输入你要注册的密码:')with open('list_of_info',mode='w',encoding='utf-8') as f:    f.write('{}\n{}'.format(username,password))print('恭喜您,注册成功')lis = []i = 0while i < 3:    usn = input('请输入你的用户名:')    pwd = input('请输入你的密码:')    with open('list_of_info',mode='r+',encoding='utf-8') as f1:        for line in f1:            lis.append(line)    if usn == lis[0].strip() and pwd == lis[1].strip():        print('登录成功')        break    else:print('账号和密码错误')    i+=1

 

  

转载于:https://www.cnblogs.com/aj-AJ/p/10801244.html

你可能感兴趣的文章
【POJ 3461】Oulipo
查看>>
Alpha 冲刺 (5/10)
查看>>
使用Siege进行WEB压力测试
查看>>
斑马为什么有条纹?
查看>>
android多层树形结构列表学习笔记
查看>>
Android_去掉EditText控件周围橙色高亮区域
查看>>
《构建之法》第一、二、十六章阅读笔记
查看>>
Git Stash用法
查看>>
sql server 2008学习8 sql server存储和索引结构
查看>>
Jquery radio选中
查看>>
memcached 细究(三)
查看>>
RSA System.Security.Cryptography.CryptographicException
查看>>
[解题报告] 100 - The 3n + 1 problem
查看>>
Entity Framework 学习高级篇1—改善EF代码的方法(上)
查看>>
Mybatis逆向工程配置文件详细介绍(转)
查看>>
String类的深入学习与理解
查看>>
OnePage收集
查看>>
yahoo的30条优化规则
查看>>
[CCF2015.09]题解
查看>>
[NYIST15]括号匹配(二)(区间dp)
查看>>