zoukankan      html  css  js  c++  java
  • 查询

    def fecth(data):
       print('33[1:43m这是查询33[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('33[1:43m这是查询33[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('33[1:43m%s33[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)
  • 相关阅读:
    线程应用示例
    Microsoft Visual Studio 2005 BETA2最新资源大杂烩
    135,139,445端口的关闭方法
    开源软件新时代 55个经典开源Windows工具
    图书商城项目总论
    无处不在的XML
    ADO.NET实例教学一
    递归
    手写代码生成器
    数据库的应用详解三
  • 原文地址:https://www.cnblogs.com/wfl9310/p/9011150.html
Copyright © 2011-2022 走看看