The cmp() function of the filecmp module can be used to compare two files. It compares the files and returns True if they seem equal, and False otherwise.
filecmp.cmp(f1, f2, shallow=True)
Here is an example:
from filecmp import cmpif cmp(file1 file2): print("Files are same")else: print("Files are not same")
from filecmp import cmp
if cmp(file1 file2):
print("Files are same")
else:
print("Files are not same")