在写python查询功能模块时,运行结果出现如下所示情况,请问该如何修改
def fecth(data):
print('这是查询功能')
print('用户数据是',data)
backend_data='backend %s\n'%data
with open('haproxy.conf','r') as read_f:
tag=False
for read_line in read_f:
if read_line.strip()==backend_data:
tag=True
continue
if tag:
print(read_line,end='')
if read_line.startswith('backend'):
tag=False
def add():
pass
def change():
pass
def delete():
pass
if __name__=='__main__':
msg='''
1:查询
2:添加
3:修改
4:删除
5:退出
'''
msg_dic={
'1':fecth,
'2':add,
'3':change,
'4':delete,
}
while True:
print(msg)
choice=input('请输入你的选项:').strip()
if not choice:continue
if choice=='5':break
data=input('请输入你的数据:').strip()
msg_dic[choice](data)

不知道你这个问题是否已经解决, 如果还没有解决的话:
如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^