Python fuzzy query

Source: Internet
Author: User

#!/bin/env python#coding:utf-8filename =  '/py/day01/contact/userinfo ' init_username =  ' Frame ' init_password =  ' frame ' success = 0while true:    username  = raw_input ("username: "). Strip ()     password = raw_input (" password:  "). Strip ()     if username == init_username:         while password != init_password:             password = raw_input ("Password error,try  again:  "). Strip ()         else:             print  "Welcome to use the program"              success = 1             break    else:        print  " Username error "#当用户登录成功时, execute this code if success == 1:    while true:         search_name = raw_input ("Search Name: "). Strip () #当用户输入的是quit时, exit program         if search_name ==  ' Quit ':             break# If the user does not enter anything, all entries are displayed          if not search_name:             userinfo = file (filename)              info = userinfo.readlines ()              userinfo.close ()              for items in info:                 print items, #使用match变量实现模糊查询         else:             userinfo = file (filename)              match = 0             while True:                 info = userinfo.readline () #当info的长度为0时, Note that the contents of the UserInfo file have been read, close the file, and exit the current loop                  if not len (Info):                      userinfo.close ()            &nbSp;         break# uses the member relationship action (in) to implement the fuzzy query, and if so, displays the entry and sets the match =  1                if  search_name in info:                     print  "match item: %s"  % info                      match = 1# If there has been no match, match is 0             if match == 0:                 print  "No match item"

This article is from the "Hezhang" blog, make sure to keep this source http://hezhang.blog.51cto.com/1347601/1700594

Python fuzzy query

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.