filecmp [文件目录比较]

    filecmp.cmp('/etc/passwd', '/etc/passwd')     # 比较两文件是否一致

    # 比较两目录下文件是否一致
    from filecmp import dircmp
    def print_diff_files(dcmp):
        for name in dcmp.diff_files:
            print "diff_file %s found in %s and %s" % (name, dcmp.left, dcmp.right)
        for sub_dcmp in dcmp.subdirs.values():
            print_diff_files(sub_dcmp)

    dcmp = dircmp('dir1', 'dir2')
    print_diff_files(dcmp)
文档更新时间: 2018-11-21 17:38   作者:RuM