Created
March 21, 2018 14:31
-
-
Save naiaden/3bd3420586eb22d103a7779602391e7b to your computer and use it in GitHub Desktop.
Returns the differences between strings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import difflib | |
| import sys | |
| if len(sys.argv) < 3: | |
| print("Usage: %s string1 string2" % sys.argv[0]) | |
| sys.exit() | |
| a = sys.argv[1] | |
| b = sys.argv[2] | |
| s = difflib.SequenceMatcher(None, a, b) | |
| for tag, i1, i2, j1, j2 in s.get_opcodes(): | |
| print ("%7s a[%d:%d] (%s) b[%d:%d] (%s)" % | |
| (tag, i1, i2, a[i1:i2], j1, j2, b[j1:j2])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment