• 用户交互程序


    flog = True   #退出多重循环使用
    count = 0
    while count < 3:
    _username = input('用户名:')
    _password = input('密码:')
    f1 = open(file='信息.txt',mode='r',encoding='utf-8')
    for line1 in f1:
    line1 = (line1.split())
    username1 = line1[0]
    if _username in username1:
    flog = False
    print('该用户已被锁定,无法登陆!!')
    break#如果上述条件成立,则for循环退出
    f1.close()
    if not flog:
    break #如果上述条件成立,则while循环退出
    f = open(file='用户信息.txt',mode='r',encoding='utf-8')
    for line in f:
    line = (line.split())
    username = line[0]
    password = line[1]
    if _username == username and _password == password:
    flog = False
    print('登陆成功! 欢迎%s登陆'%(_username))
    break #如果上述条件成立,则for循环退出
    f.close()
    if not flog: #如果上述条件成立,则while循环退出
    break
    else:
    print('用户名或密码错误!!')
    count += 1
    if count == 3:
    f1 = open(file='信息.txt',mode='a+',encoding='utf-8')
    f1.write('%s %s '%(_username,_password))
    f1.close()
    else:
    exit()
  • 相关阅读:
    四则运算 2
    《你的灯亮着吗》读后感 (前两篇)
    四则运算设计思路
    读书目标
    课堂总结
    人月神话感想
    软件工程概论11
    软件工程概论10
    bnu——GCD SUM (莫比乌斯反演)
    POJ1108_Split Windows 解题报告
  • 原文地址:https://www.cnblogs.com/wzq1997/p/12968696.html
Copyright © 2020-2023  润新知