编写登陆接口
- 输入用户名密码
- 认证成功后显示欢迎信息
- 输错三次后锁定
代码如下: #!/usr/bin/env python# -*- coding: utf-8 -*- count = 0 name = "hx"passwd = "123" f = open (‘user_black‘,‘r‘ )lock_file = f.read()f.close() name = input("请输入用户名:") for i in range(1): if lock_file == name: print ("sorry,锁定了") exit() else: continue for i in range(3): passwd = input("请输入密码:") if passwd == "123": print ("welcome") break else: print ("登录失败!") count += 1 if count == 3: print("用户已锁定") f = open (‘user_black‘,‘w‘ ) f.write(‘%s‘%name) f.close()
时间: 2024-09-30 18:36:34