学习笔记-登录-总是报错,不知道哪的问题

import os

jd_user_path = 'jd_users.txt'
jd_wx_path = 'wx_users.txt'
user_status = False


def allinlogin(filepath):
    with open(filepath, 'r') as file:
        users = file.readlines()
        username = input("请输入用户名:")
        password = input("请输入密码:")
        for i in users:
            nameandpass = i.split(',')
            if username == nameandpass[0] and password == nameandpass[1]:
                print("登录成功")
                user_status = True
                return True
        print("用户名或密码错误!")
    return False


def jd_login():
    allinlogin('jd_users.txt')


def wx_login():
    allinlogin('wx_users.txt')


def user_login():
    def login(auth_type = 'jingdong'):
        if user_status:
            if auth_type == 'jingdong':
                jd_login()
            elif auth_type == 'weixin':
                wx_login()
    return login

@user_login()
def jd_home(auth_type):
    print("welcome jd home...")


@user_login()
def jd_finance(auth_type):
    print("welcome jd finance...")


@user_login()
def jd_book(auth_type):
    print("welcome jd book...")


while True:
    print("1.Home")
    print("2.finance")
    print("3.book")
    user_select = input(">>")
    if user_select == '1':
        jd_home('jingdong')
    elif user_select == '2':
        jd_finance('weixin')
    elif user_select == '3':
        jd_book('weixin')
    else:
        print("选择错误,请重新选择")
        continue

 

posted on 2018-11-06 20:59  开小开  阅读(121)  评论(0)    收藏  举报

导航