首页 > 代码库 > 文件内容的增删改查

文件内容的增删改查

技术分享
global
        log 127.0.0.1 local2
        daemon
        maxconn 256
        log 127.0.0.1 local2 info
defaults
        log global
        mode http
        timeout connect 5000ms
        timeout client 50000ms
        timeout server 50000ms
        option  dontlognull

listen stats :8888
        stats enable
        stats uri       /admin
        stats auth      admin:1234

frontend oldboy.org
        bind 0.0.0.0:80
        option httplog
        option httpclose
        option  forwardfor
        log global
        acl www hdr_reg(host) -i www.oldboy.org
        use_backend www.oldboy.org if www

backend www.oldboy1.org
        server 10.10.0.10 10.10.0.10 weight 9999 maxconn 33333333333
        server 10.10.10.1 10.10.10.1 weight 22 maxconn 2000
        server 2.2.2.4 2.2.2.4 weight 20 maxconn 3000
backend www.oldboy2.org
        server 3.3.3.3 3.3.3.3 weight 20 maxconn 3000
backend www.oldboy20.org
        server 10.10.0.10 10.10.0.10 weight 9999 maxconn 33333333333
源文件

 1.查询功能:

  当用户输入www.oldboy1.org用户信息后,打印对应的server信息:
  server 10.10.0.10 10.10.0.10 weight 9999 maxconn 33333333333
  server 10.10.10.1 10.10.10.1 weight 22 maxconn 2000
  server 2.2.2.4 2.2.2.4 weight 20 maxconn 3000 

while 1:
    l=[]
    flag=1
    m=input("please input your choise:").strip()
    with open("test",encoding="utf8") as f:
        for i in f:
            if i.startswith("backend") and m in i:
                flag=0
                continue
            if i.startswith("backend") and flag==0:
                break
            if flag==0:
                l.append(i)
        for p in l:
            print(p.strip())

 

  

 

  

 

  

 

 

 

 

文件内容的增删改查