我使用的是Python2.6.2。docs for the filecmp module说:
The filecmp module defines functions to compare files and directories, with various optional time/correctness trade-offs.
以及,对于filecmp.cmp函数:
filecmp.cmp(f1, f2[, shallow])
Compare the files named f1 and f2, returning True if they seem equal, False otherwise.
Unless shallow is given and is false, files with identical os.stat() signatures are taken to be equal.
他们不做的是指定用shallow=False
获得的正确性级别。那么,shallow=False
做什么呢?有多正确?
查阅source ^{} 可以发现,如果
shallow=False
,filecmp.cmp
通过读取和比较每个文件的块来进行精确的内容比较。只有当两个文件的内容完全相同时,它才返回True
。相关问题 更多 >
编程相关推荐