zgdy 发表于 2018-8-11 10:08:09

Python-w1

#!/usr/bin/env python  # -*- coding: utf-8 -*-
  user_allow = []
  user_deny = []
  while True:
  banner = "Welcome"
  print(banner.center(20,"="))
  if user_allow:
  for i in range(3):
  banner_login = "Please enter your name and password to login!"
  print(banner_login)
  lname = input("Login Name:")
  lpwd = input("Login Password:")
  if user_deny:
  for m in range(len(user_deny)):
  if lname == user_deny:
  print("It is locked. Please contract your administrator !")
  else:
  pass
  for n in range(len(user_allow)):
  if lname == user_allow and lpwd == user_allow:
  print("Welcome %s to login !" % lname)
  select = input("List| Reset password | Users| Logout:")
  if select == "l":
  for luser in range(len(user_allow)):
  print(user_allow)
  break
  elif select == "x":
  print("Logout! Bye bye !")
  break
  elif select == "c":
  print("Now reseting the password...")
  opwd = input("Your old password:")
  npwd = input("Your new password:")
  npwd2 = input("Confirm:")
  if npwd == npwd2:
  if opwd == user_allow:
  user_allow = npwd2
  print("The password is updated!")
  else:
  print("It is not match !")
  continue
  elif select == "a":
  print("==Add new user info==")
  add_user = input("The new account:")
  add_pwd1 = input("The password:")
  add_pwd2 = input("Confirm:")
  if add_user not in user_allow and add_pwd1 == add_pwd2:
  user_allow.append()
  print("The user is added.")
  continue
  else:
  print("It is not match!")
  continue
  else:
  i = 2 - i
  if i > 0 and i <=2 :
  print("Sorry,you have %s times" % i)
  elif i == 0:
  print("Sorry,your account is locked!")
  user_deny.append()
  exit()
  else:
  print("Please register first!")
  uname = input("New Name:")
  upwd = input("New Password:")
  user_allow.append()
  print("The register is successful !")
页: [1]
查看完整版本: Python-w1