Day1 登录接口脚本 login.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- user_name = "jiafei" password = "abc123" count = 0 while True: if count < 3: name = input("Please input your name: ") passwd = input("Please input password: ") if (name == user_name) & (passwd == password): print("Welcome to login") break elif (name != user_name) | (passwd != password): count += 1 continue else: print("Your is 3 ci ERROR!!!") break
2.第二种方式
#!/usr/bin/env python3 # -*- coding: utf-8 -*- user_name = "jiafei" password = "abc123" for i in range(3): name = input("Please input your name: ") passwd = input("Please input password: ") if (name == user_name) & (passwd == password): print("Welcome to login") break elif (name != user_name) | (passwd != password): continue