python模糊查詢
#!/bin/env python
#coding:utf-8
filename = '/py/day01/contact/userinfo'
init_username = 'frame'
init_password = 'frame'
success = 0
while 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"
#當使用者登入成功時,執行此段**
if success == 1:
while true:
search_name = raw_input("search name: ").strip()
#當使用者輸入的是quit時,退出程式
if search_name == 'quit':
break
#如果使用者沒有輸入任何內容,則顯示所有條目
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時,說明userinfo檔案的內容已經讀取完畢,則關閉該檔案,並退出當前迴圈
if not len(info):
userinfo.close()
break
#使用成員關係操作(in)實現模糊查詢,如果匹配,則顯示該條目,並設定match = 1
if search_name in info:
print "match item: %s" % info
match = 1
#如果一直都沒有匹配,則match為0
if match == 0:
print "no match item"
無名521
python 模糊搜尋檔案
usr bin env python coding utf 8 time 2019 1 21 18 57 author xiaodai import ospath r f temp test files os.listdir path for f in files if f.endswith png...
zTree模糊搜尋
根據搜尋的值重新顯示整個ztree 1 輸入框 2 js chatgroupserarchbtn click function function doqueryalg4name value treeobj.shownodes nodelist 指定被顯示的節點 json 資料集合 if value ...
ztree模糊搜尋
1 方法 function 載入樹方法和事件 function searchdepart newdepartcontroller.do?gettreedata datatype json data success function list var setting check view data c...