python's search function

def fetch(a):
print('这是所要查询的内容')
backend_data = 'backend %s'% a
with open('haproxy.conf','r') as f:
Itag=False
res=[]
for i in f:
if backend_data==i.strip():
Itag=True
continue
if Itag and i.startswith('backend'):
break
if Itag:
print(i,end='')
res.append(i)
return res

def add():
pass
def delete():
pass
def change():
pass
if __name__=='__main__':
msg='''
1: Query
2: Increase
3: Delete
4: Review
5: Release

'' '
msg_txt = {
'. 1 ': FETCH,
' 2 ': the Add,
' 3 ': Delete,
' 4 ': Change,
' 5 ': Exit
}
the while True :
Print (msg)
RES = the iNPUT ( 'Please input options:') Strip ().
IF not RES:
the Continue
IF RES == 5:
BREAK
the data = the iNPUT ( 'user enter data to be queried:')
RET = msg_txt [RES] (Data)
Print (RET)

Guess you like

Origin www.cnblogs.com/cxydnxs/p/12295301.html