python读取mtcars数据集并实现以下操作_python读取文件数据实现简单的注册操作

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值