![]() ![]() This function makes comparison of files in two directories and returns a three item tuple. > filecmp.cmp('dir1/file2.txt', 'dir2/file2.txt')įalse filecmp.cmpfiles(dir1, dir2, shallow) ![]() > filecmp.cmp('dir1/file1.txt', 'dir2/file1.txt', shallow = False) If shallow is set to False, only the contents are compared.īased on our file structure, following code yields the output as shown − Differing files : Hence the file metadata is considered for comparison in addition to contents. The shallow parameter is True by default. This function compares the two files and returns True if they are identical, False otherwise. Let us now describe various comparison functions in filecmp module. Two directories dir1 and dir2 are first created under current working directory. This comparison takes into consideration the properties of files in addition to data in them.Įxample codes in this article use following file and directory structure. Python’s standard library has filecmp module that defines functions for comparison of files and directories. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |