Comparing contents of txt files in Python -


i trying write program open files, read contents , compare them other files opened. need show if not close enough alike, similar, or exact copies of each other. trying use filecmp module, it's not working me. here's have far:

import filecmp  #opens selected files file1 = open('file1.txt') file2 = open('file2.txt')  #compares different files filecmp.cmp('file1','file2', shallow=false)  #closes files filecmp.clear_cache() close.file1 close.file2 

any suggestions?

>>> import filecmp >>> filecmp.cmp('c://desktop/a.txt', 'c://desktop/b.txt') true >>>  

in case have 2 text files a.txt , b.txt. both files contain same 1 line of string.

if change string in 1 of files different, output false


Comments