Skip to content

Commit b0649d9

Browse files
authored
Add files via upload
1 parent 10c3d93 commit b0649d9

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

homework1-day1.py

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env python
2+
# -*-conding:utf-8-**
3+
# __Author__:'liudong'
4+
#!/usr/bin/env python
5+
# -*-coding:utf-8-*-
6+
# __author__="Life"
7+
login_user = 'life'
8+
login_passwd = '7777'
9+
print('You have three times to login,otherwise your account will be locked!')
10+
for i in range(3):
11+
username = input('Please input your username:')
12+
password = input('Please input your password:')
13+
lock_file = open('account_lock.txt', 'r')
14+
lock_list = lock_file.readlines() # 已经被锁定用户清单文件
15+
for lock_line in lock_list: #判断用户输入的名字是否已经锁定(在锁定的文件列表中)
16+
lock_line = lock_line.strip('\n')
17+
if username == lock_line:
18+
print('Your account is locked!')
19+
lock_file.close()
20+
exit()
21+
if username == login_user and password == login_passwd:
22+
print('login successed!')
23+
break
24+
else:
25+
print('Invalid username or password...')
26+
print('this is the %d time(s)' % (i + 1))
27+
continue
28+
if i >= 2:
29+
print('Your account is locked! Please,contact adminstrator to unlock your account!')
30+
lock_file = open('account_lock.txt', 'w')
31+
lock_file.write(username + '\n') #锁定用记名写入锁定文件
32+
lock_file.close()

0 commit comments

Comments
 (0)