Python first day job login three error lock account

Source: Internet
Author: User

Write so rotten, are embarrassed to start, later think after all is the first PY program, or at work time secretly written, take out to do a memorial it,

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/80/1C/wKiom1c4DPrzzKr-AACfV0QyuEs183.png "title=" OR Template.png "alt=" Wkiom1c4dprzzkr-aacfv0qyues183.png "/>

# -*- coding:utf-8 -*-#!/usr/bin/env pythonimport osimport os.pathusername  =  "Liulidong" password =  "123456" K = 1for i in range (Ten):       if not os.path.exists ('/tmp/lock.txt '): #  determine if the dictionary file exists               os.system ("Touch /tmp/lock.txt")        output = open ('/tmp/lock.txt ', ' r ')  #  open dictionary file        read = output.read ()                 #  Reading dictionary content       arr= read.split (';')                 #以, separating, converting strings to arrays        user = input ("please input your username: ")    #  Enter user name &nbsP;     passwd = input ("please input your password: ")   #输入密码       for n in range (0, len (arr)):           if user == arr[n]:               print ("your name is lock  Please mail to administrator ")                os._exit (1)       #循环判断用户是否在字典中        if username == user and password == passwd:           print ("Welcome to linux")              #输入正确返回欢迎信息           break       else:          k+=1           print ("Your name or password is wrong")            if k > 3:                          #   output three records inside the file              output =  open ('/tmp/lock.txt ', ' a ')               Output.write (user +  '; ')              output.close ()               print ("you test too many,your  Username will be lock ")               break 




Please execute this script with Python3 under Linux


Python first day job login three error lock account

Related Article

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.