|
一、需求
编写一个用于验证员工登录并采集员工信息的接口
- 员工尝试登录次数为3次,超过三次被锁定
- 员工输入个人信息并存档,可重复输入两次,若两次输入个人信息错误,则程序结束
二、代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
| #!/usr/bin/env python
#_*_coding:utf-8_*_
import sys
from imaplib import Continuation
username = 'mangguo'
password = 'json'
try_time = 0
while try_time < 3:
username_input = raw_input('input your username:')
if username_input == username:
password_input = raw_input('input your password:')
if password_input == password:
print 'Welcome,%s',username
try_time+=1
break
else:
print 'password ERROR!'
try_time+=1
continue
else:
print 'username ERROR!'
try_time+=1
continue
else:
print 'login fail!'
sys.exit()
sex = raw_input('input your sex:')
age = int(raw_input('input your age:'))
job = raw_input('input your job:')
print 'your infornation:'
print ('username:%s,sex:%s,job:%s,age:%d')%(username,sex,job,age)
choice = raw_input('the information is right?(Y/N)')
yes = 'Y'
no = 'N'
while choice == yes:
print 'finished!'
sys.exit()
else:
sex = raw_input('input your sex again:')
age = int(raw_input('input your age again:'))
job = raw_input('input your job again:')
choice_1 = raw_input('the information is right?(Y/N)')
if choice_1 == yes:
print 'finished!'
sys.exit()
else:
print 'input information ERROR!'
sys.exit()
|
|
|