2014年1月21日 星期二

difference between two strings in python

import difflib

s1 = "abcdefghijklmnop"
s2 = "abcdefghi"
s = difflib.SequenceMatcher(a=s1, b=s2)
for block in s.get_matching_blocks():
    print "match at a[%d] and b[%d] of length %d" % block

ref. http://stackoverflow.com/questions/1209800/difference-between-two-strings-in-python-php

沒有留言:

張貼留言