• Python小脚本


    #########################################################################
    #@@@@@@fuction: 域名解析 #@@@@@@author: hejoy #@@@@@@date : 2017
    wget http://www.dnspython.org/kits/1.9.4/dnspython-1.9.4.tar.gz tar -xzvf dnspython-1.9.4.tar.gz cd dnspython-1.9.4 python setup.py install [root@zy code]# cat simple.py #!/usr/bin/env python import dns.resolver domain=raw_input('please input an domain:') REST=dns.resolver.query(domain,'REST') for i in REST.response.answer: for j in i.items: print j.address [root@zy code]# python simple.py please input an domain:google.com 74.125.23.113 74.125.23.102 74.125.23.138 74.125.23.100 74.125.23.139 74.125.23.101

     比较两个字符串的不同之处

    #!/usr/bin/env python
    
    
    import difflib
    textchar="""textchar:
            this molde provides classes and functions for comparing sequences.
    including HTML and context and unified diffs.
    difflib document v7.4
    and string
    """
    textchar_lines=textchar.splitlines()
    textchar1="""textchar:
            this molde provides classes and functions for comparing sequences.
    including HTML and context and unified diffs.
    difflib document v7.5"""
    textchar1_lines=textchar1.splitlines()
    d=difflib.Differ()
    diff=d.compare(textchar_lines,textchar1_lines)
    print '
    '.join(list(diff))


    [root@zy code]# python simple2.py
    textchar:
    - this molde provides classes and functions for comparing sequences.
    ? ^

    + this molde provides classes and functions for comparing sequences.
    ? ^^^^^^^^

    including HTML and context and unified diffs.
    - difflib document v7.4
    ? ^

    + difflib document v7.5
    ? ^

    - and string
    [root@zhiyu code]# vim simple2.py
    [root@zhiyu code]# python simple2.py
    textchar:
    - this molde provides classes and functions for comparing sequences.
    ? ^

    + this molde provides classes and functions for comparing sequences.
    ? ^^^^^^^^

    including HTML and context and unified diffs.
    - difflib document v7.4
    ? ^

    + difflib document v7.5
    ? ^

    - and string

     

  • 相关阅读:
    prettier 与 eslint 对比
    vscode快捷键补充
    什么是函数式编程
    让Chrome看不了WWDC直播的HLS技术详解
    IPv6启动五年后,距离我们究竟还有多远?
    WebSocket+MSE——HTML5 直播技术解析
    为什么各大厂商要抢先跟进H.265?
    如何通过 WebP 兼容减少图片资源大小
    IPv6,AppStore 审核不是唯一选择它的原因
    为什么非全站升级HTTPS不可?
  • 原文地址:https://www.cnblogs.com/st12345/p/6429686.html
Copyright © 2020-2023  润新知