Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # difflib_ndiff.py
- import difflib
- case=[("IsN't Pyth0n GrEaT?", 'Python Is Great!')]
- for a,b in case:
- print('{} >>> {}'.format(a,b))
- aaa = list(a)
- bbb = list(b)
- print(''.join(aaa))
- for i,s in enumerate(difflib.ndiff(a, b)):
- if s[0]==' ': continue
- elif s[0]=='-':
- aaa[i] = ''
- elif s[0]=='+':
- aaa.insert(i, s[-1])
- print(''.join(aaa))
- print('')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement