filecmp --- 檔案與目錄比較¶
原始碼:Lib/filecmp.py
The filecmp module defines functions to compare files and directories,
with various optional time/correctness trade-offs. For comparing files,
see also the difflib module.
filecmp 模組定義了以下函式:
- filecmp.cmp(f1, f2, shallow=True)¶
Compare the files named f1 and f2, returning
Trueif they seem equal,Falseotherwise.If shallow is true and the
os.stat()signatures (file type, size, and modification time) of both files are identical, the files are taken to be equal.Otherwise, the files are treated as different if their sizes or contents differ.
Note that no external programs are called from this function, giving it portability and efficiency.