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

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python实现登录查询(可以模糊查询)相关的知识,希望对你有一定的参考价值。

# -*- 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."

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

技术分享


执行结果:


技术分享


技术分享

本文出自 “天道酬勤” 博客,请务必保留此出处http://taindaochouqin.blog.51cto.com/12995943/1947894

以上是关于python实现登录查询(可以模糊查询)的主要内容,如果未能解决你的问题,请参考以下文章

Python 代码实现模糊查询

10 行 Python 代码实现模糊查询/智能提示

微信小程序 连接云数据库(不使用云函数)进行 登录注册查询(包括模糊查询)快速实现 亲测可用

SQL 怎么实现模糊查询?

怎样基于Redis实现模糊查询

js如何实现模糊查询