函数式编程做用户登陆注册练习-pycharm上

def login(username,password):
"""
用户登陆
:param username: 用户名
:param password:密码
:return:返回值
"""
f1 = open('database','r')
for line in f1:
line_list = line.strip().split('|')
if line_list[0] == username and line_list[1] == password:
return True
return False

def register(username,password):
pass




def main():
choice = input("1:登陆;2:注册")
if choice =='1':
print('登陆')
user = input('用户名:')
passwd = input('密码:')
ret = login(user,passwd)
if ret == True:
print('登陆成功')
else:
print('登陆失败')
elif choice =='2':
print('注册')
user = input('用户名:')
passwd = input('密码:')
register(user,passwd)
main()
原文地址:https://www.cnblogs.com/cfj271636063/p/5726390.html