发布时间:2019-08-27 08:02:02编辑:auto阅读(1647)
username = 'test'
password = '123456'
while True:
user_str = raw_input("Please input your name>>")
pass_str = raw_input("Please input your password>>")
if username != user_str or password != pass_str:
print "Sorry,You input wrong username or password!"
continue
else:
print "Login successfully!"
while True:
flag = 0
input_str = raw_input("Please input name what do you to search>>")
filestr = open('D:/myPython/name_list.txt','rb+')
if input_str == 'exit' or input_str == 'quit':
filestr.close()
exit()
elif input_str == 'list all':
line_str = filestr.readline()
while len(line_str) != 0:
line_str = line_str.strip('\n')
print line_str
line_str = filestr.readline()
flag = 1
while True:
line = filestr.readline()
if len(line) == 0:
break
line = line.strip('\n')
line_behind = line.split(' ')
if input_str in line:
print line
flag = 1
else:
pass
if flag != 1:
print "Sorry,%s has found." %input_str 测试的要求如下:
1:验证登录
2:读取信息文件列表
3:全文搜索功能,包括精确匹配,模糊查找,遍历打印,退出功能
这是我对自己最近学习Python的一个小测试吧,可能会存在问题,大家如有发现,敬请指出。
上一篇: python模拟鼠标点击window图标
下一篇: Python工作路径sys.path修改
51265
50705
41307
38125
32582
29489
28346
23207
23178
21502
1577°
2296°
1906°
1847°
2159°
1890°
2576°
4318°
4167°
2973°