python_for_else_return

def login():
    # 登录
    # 登录 输入用户名密码
    # 和self.user_list作比对
    while True:
        username = input('用户名 :')
        # password = input('密  码 :')
        # user_list=SC.getallstudents()
        user_list=["a","b","c","d"]
        for user in user_list:
            if username == user:
                print('登录成功')
                return user   # 退出 for in及 while循环
        else:
            print('登录失败')

print(login())

posted @ 2020-06-02 22:25  collin_pxy  阅读(202)  评论(0编辑  收藏  举报