First week of Python learning-Account Logon exercise, first week of python

Source: Internet
Author: User

First week of Python learning-Account Logon exercise, first week of python

Python learning started at the end of November 2017. Select python 3.6.

Rough Implementation of account login.

 1 import getpass 2  3 wall = True 4 usr = 'root' 5 paswd = 0000 6 block_list = open("test.txt", 'a') 7 print("Please sign in!") 8  9 for i in range(3, 0, -1):10     print('{time} time(s) left'.format(time=i))11     usr_in = input("username: ")12     paswd_in = int(input("password:"))  #13     # password = getpass.getpass("password:")14 15     for line in open('test.txt'):16         if line == usr:17             print('Your account is blocked!')18             wall = False19             break20 21     if wall is False:22         print('Call you admin!')23         break24     elif usr == usr_in and paswd_in == paswd:25         print('------ Welcome {_name}! ------'.format(_name=usr))26         break27     else:28         if i != 1:29             print('Invalid password or username!\nPlease try again!')30         else:31             print('Your account is blocked!\nCall your admin!')32             block_list.writelines('{0}'.format(usr))33 34 block_list.close()

 

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.