首页 > 编程语言 > 详细

python之查询功能

时间:2020-02-11 17:02:13      阅读:78      评论:0      收藏:0      [点我收藏+]
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)

python之查询功能

原文:https://www.cnblogs.com/cxydnxs/p/12295301.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!