DAY7课下作业

  认证功能

    #db.txt(abc:111

        def:222

        ghi:333)

    inp_name=input('请输入你的名字: ').strip()

    inp_pwd=input('请输入你的密码: ').strip()

    with open(r'db.txt',mode='rt',encoding='utf-8') as f:

      for line in f:

        u,p=line.strip(' ').split(':')

        if inp_name == u and inp_pwd == p:

          print('登录成功')

          break

      else:

        print('账号名或者密码错误')

原文地址:https://www.cnblogs.com/lipengjia/p/9676499.html