#!/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('注册成功')