filecmp是python的标准库自带的模块
[root@www difflib]# vim diff_one_file.py
!/usr/bin/env python
import filecmp
test1 =raw_input("please input you test1 An absolute path : ")
test2 =raw_input("please input you test2 An absolute path : ")
contrast = filecmp (test1,test2)
print contrast
创建一个文件的备份,然后对其备份进行修改。
[root@www difflib]# cp diff.html diff.htmlv2
[root@www difflib]# echo aaaa>>diff.htmlv2
测试:
[root@www difflib]# python diff_one_file.py
please input you test1 An absolute path : /root/python_auto/difflib/diff.html
please input you test2 An absolute path : /root/python_auto/difflib/diff.htmlv2
False
网友评论