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)
  • 相关阅读:
    Python遇上嵌入式:几款主流的Python开发板一览!
    shell入门(二):()、(())、[]、[[]]、{}
    Shell入门(一)
    Android Studio打开项目,停在gradle的解决方案
    安装vim中文帮助vimcdoc
    多选框(全选反选)-html
    select框右移-html
    记时器带暂停-html
    浮窗广告html
    js中的dom
  • 原文地址:https://www.cnblogs.com/wfl9310/p/9011150.html
Copyright © 2011-2022 走看看