Python3 Job: Impersonation Login

Source: Internet
Author: User

__author__ = "bin007"

Customer = {} #存储用户信息
#处理用户信息文件
Try
With open (' Login.txt ', ' R ', encoding= ' utf-8 ') as F:
For line in F:
Customer[line.split () [0]] = [Line.split () [1],line.split () [2]]
Except
Print (' User file does not exist ')

Login_name = input ("\033[32;1m Please enter user name-->:\033[0m") #获取用户名
Login_secret = input (' \033[32;1m Please enter the password--->:\033[0m ') #获取用户密码
If Customer.get (login_name):
Customer_secret = Customer.get (login_name) [0]
secret_err = Int (Customer.get (login_name) [1])
If Secret_err < 3:
if Login_secret = = Customer_secret:
Print (' \033[32;1m login successful \033[0m ')
Else
Print (' \033[31;1m user name or password error, remaining%s chance \033[0m '% (2-secret_err))
Customer.get (login_name) [1] = str (int (customer.get (login_name) [1]) +1)
Else
Print (' \033[41;1m user is locked \033[0m ')
Customer.get (login_name) [1] = str (int (customer.get (login_name) [1]) +1)
Print (Customer.get (login_name) [1])
Else
Login_new = input (' \033[31;1m user does not exist whether to register with the current user name password (y/n): \033[0m ')
if login_new = = ' Y ' or login_new = = ' Y ':
Customer[login_name] = [login_secret,0]
Print (' \033[32;1m registration is successful, please login to \033[0m ')
Else
Pass
#更新用户文件
With open (' Login.txt ', ' w+ ', encoding= ' utf-8 ') as F:
For I in Customer:
Write_line = ('%s%s ' + ' \ n ')% (i,customer[i][0],customer[i][1])
F.write (Write_line)


Python3 Job: Impersonation Login

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.