Python Homework 001

 

 1 #!/usr/bin/env python
 2 #-*- coding:utf-8 -*-
 3 
 4 import getpass
 5 name = "xilong"
 6 password = "--------"    #input your password
 7 workid = 10008179
 8 
 9 file = open("xilong.txt", "r+", encoding="utf-8") #create a file called xilong.txt first.
10 count = 0
11 while count < 3:
12     _name = input("name:")
13     _mima = getpass.getpass("password:")
14     _workid = int(input("workid:"))
15     namelist = file.readlines()
16     mingzi = _name + "\n"
17     if mingzi in namelist:
18         print("This account has been locked!")
19         break
20     if _name == name and _mima == password and _workid == workid:
21         print("Welcome to Visit StarTimes Operation&Maintenance Center!")
22         break
23     else:
24         print("Invalid Account, please try again!")
25         count += 1
26     if count == 3:
27         file.write("%s\n" %_name)
28 file.close()

 

#Becoming A Media Group with International Influence!

posted @ 2018-08-07 00:15  xilong_devops  阅读(117)  评论(0编辑  收藏  举报