Created
August 9, 2012 11:46
-
-
Save zhasm/3303542 to your computer and use it in GitHub Desktop.
compare 2 blocks of text
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
#!/usr/bin/env python | |
# -*- encoding: utf-8 -*- | |
from difflib import unified_diff | |
def getRawInput(name): | |
ret=[] | |
ret.append(raw_input("Please copy a bunch of lines as %s, and press Enter && Ctrl-D to end: \n\n" % name ).strip()) | |
while True: | |
try: | |
ret.append(raw_input().strip()) | |
except EOFError: | |
break | |
return ret | |
if __name__ == '__main__': | |
a=getRawInput('A') | |
print '\n', '='*32, '\n' | |
b=getRawInput('B') | |
for line in unified_diff(a, b): | |
print line |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment