低级方式:
from __future__ import with_statementwith open(filename1) as f1: with open(filename2) as f2: if f1.read() == f2.read(): ...
高级方式:
import filecmpif filecmp.cmp(filename1, filename2, shallow=False): ...

低级方式:
from __future__ import with_statementwith open(filename1) as f1: with open(filename2) as f2: if f1.read() == f2.read(): ...
高级方式:
import filecmpif filecmp.cmp(filename1, filename2, shallow=False): ...