import difflib # Read the contents of the two files with open('file2.txt') as f1, open('file2.txt') as f2: text1 = f1.read() text2 = f2.read() # Compare the sequences of characters in the two files # and compute their similarity matcher = difflib.SequenceMatcher(None, text1, text2) similarity = matcher.ratio() # Print the similarity score print(similarity)