码迷,mamicode.com
首页 > 编程语言 > 详细

python读取文件数据实现简单的注册操作

时间:2019-11-21 16:43:43      阅读:63      评论:0      收藏:0      [点我收藏+]

标签:name   数据   txt   open   readlines   data   adl   pytho   注册   

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2019-11-21 14:32
# @ player :zhaohq
# @Email : 909095763@qq.com
# @File : zhuc.py
name = input(‘name:‘)
with open(‘zhuc.txt‘, ‘a‘) as fo:
with open(‘zhuc.txt‘, ‘r‘) as fo:
data = fo.readlines() # 读取信息到data
count = data.__len__() # 计算data数据量
i = 0
while i < count:
with open(‘zhuc.txt‘, ‘r‘) as fo1:
data = fo1.readlines() # 读取信息到data
count = data.__len__() # 计算data数据量
str1 = data[i]
str2 = str1[:str1.rfind(‘\t‘)] # 读取用户名
if name == str2:
print(‘用户名已注册,请输入其他用户名‘)
name = input(‘name:‘)
i = 0
continue
else:
i = i+1
continue
else:
password = input(‘password‘)
with open(‘zhuc.txt‘, ‘a‘) as fo:
fo.writelines([name, ‘\t‘, password, ‘\n‘])
print(‘注册成功‘)

python读取文件数据实现简单的注册操作

标签:name   数据   txt   open   readlines   data   adl   pytho   注册   

原文地址:https://www.cnblogs.com/LoongUncle/p/11906422.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!