查询
def fecth(data): print('\033[1:43m这是查询\033[0m') print('用户数据是',data) backdata='backend %s'%data with open('dog.txt','r')as read: for readline in read: if readline.strip()==backdata: continue def add(): pass def change(): pass def delete(): pass #__name__='__main__' if __name__=='__main__': # print('test') msg='' #1查询 2 添加 3修改 4删除 msgdic={ '1':fecth, '2':add, '3':change, '4':delete, } while True: print(msg) choice=input('输入你的选项:').strip()#。strip函数就是去除输入当中的空格、回车等 #也可以制定去除x.strip('*') if not choice :continue if choice=='5':break data=input('请输入你的数据:').strip() msgdic[choice](data)
def fecth(data): print('\033[1:43m这是查询\033[0m') print('用户数据是',data) backdata='backend %s'%data with open('dog.txt','r')as read:#read代表文件的行 tag=False for readline in read: if readline.strip()==backdata: tag=True continue#匹配到了直接下一次操作 if readline.startswith('backend'): # tag=False break if tag: # 为true print('\033[1:43m%s\033[0m'%readline,end='')#打印当前行 def add(): pass def change(): pass def delete(): pass #__name__='__main__' if __name__=='__main__': # print('test') msg='' #1查询 2 添加 3修改 4删除 msgdic={ '1':fecth, '2':add, '3':change, '4':delete, } while True: print(msg) choice=input('输入你的选项:').strip()#。strip函数就是去除输入当中的空格、回车等 #也可以制定去除x.strip('*') if not choice :continue if choice=='5':break data=input('请输入你的数据:').strip() msgdic[choice](data)