༺龍༒叔༻

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2019-11-21 9:19
# @ player :zhaohq
# @Email : 909095763@qq.com
# @File : day1.py
name = input('name:')
password = input('password')
count = 0
with open('test.txt', 'r') as fo:#打开文件
data = fo.readlines()#读取信息到data
# print(data)
count = data.__len__()#计算data数据量
i = 0
while i < count:
str1 = data[i]
str2 = str1[:str1.rfind('\t')]#读取用户名
str3 = str1[str1.rfind('\t'):]#读取密码
# print(str2)
# print(str3.strip())
# print(type(name), type(password), type(str1), type(str2))
if name == str2 and password == str3.strip():
print('登陆成功')
break
else:
i = i+1
continue
else:
print('用户名或密码错误')
posted on 2019-11-21 12:56  ༺龍༒叔༻  阅读(169)  评论(0)    收藏  举报