且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

python实现登录查询(可以模糊查询)

更新时间:2022-08-14 21:35:19

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
# -*- coding: utf-8 -*-
 
while 1:
    name= raw_input("Please input your name:")
 
    if name == "zhangsan":
        password = raw_input("Please input your password:")
        while password != "zhangsan":
            password = raw_input("password error,Please input your password again:")
             
        else:
            print "Login successful."
            print "welcome to search address list."
 
            while 1:
                match_yes = 0
                search = raw_input("please input name whom you want to search.")
                contact_file = file('address_list.txt')
                while 1:
                    line =  contact_file.readline()
                    if len(line) == 0:break
                    if search in line:
                        print 'Congratulations:\n\n %s' % line
                        match_yes = 1
                if match_yes == 0:
                    print "Sorry,not found"
 
 
             
         
    else:
        print "username error,try again."

查询的表:声明。电话号都是随便打的:

python实现登录查询(可以模糊查询)


执行结果:


python实现登录查询(可以模糊查询)


python实现登录查询(可以模糊查询)


本文转自 天道酬勤VIP 51CTO博客,原文链接:http://blog.51cto.com/tdcqvip/1947894