python之查询功能

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:查询
2:增加
3:删除
4:修改
5:推出

'''
msg_txt={
'1':fetch,
'2':add,
'3':delete,
'4':change,
'5':exit
}
while True:
print(msg)
res=input('请输入选项:').strip()
if not res:
continue
if res==5:
break
data=input('用户在此输入需要查询的数据:')
ret=msg_txt[res](data)
print(ret)

猜你喜欢

转载自www.cnblogs.com/cxydnxs/p/12295301.html