in:
from difflib import SequenceMatcher
print('---------------------ksv in long string')
temp='gksvlkdfvjmflkvmoiflksjvmoiflkvmoilfjvmoierlkvjfdsljfiefjvo\
isfvoiafvjfojwfdkvasldkcosxzfjirkjmcoipfvjopsnosjvjrgegrjsdijfowijfoiwjfoiwjfoiwjfoijlksvlkdfvjmfl\
kvmoiflksjvmoiflkvmoilfjvmoierlkvjfdsljfiefjvofegegewtfvasvervvwfjoiw'
print(SequenceMatcher(None, 'ksv',temp).get_matching_blocks())
print('-----------------------long string start with ksv')
temp='ksvlkdfvjmflkvmoiflksjvmoiflkvmoilfjvmoierlkvjfdsljfiefjvo\
isfvoiafvjfojwfdkvasldkcosxzfjirkjmcoipfvjopsnosjvjrgegrjsdijfowijfoiwjfoiwjfoiwjfoijlksvlkdfvjmfl\
kvmoiflksjvmoiflkvmoilfjvmoierlkvjfdsljfiefjvofegegewtfvasvervvwfjoiw'
print(SequenceMatcher(None, 'ksv',temp).get_matching_blocks())
print('-----------------------ksv in short string')
temp='gksvlkdfvjmflkvmoiflksjvmoiflkvmoilfjvmoierlkvjfdsljfiefjvo'
print(SequenceMatcher(None, 'ksv',temp).get_matching_blocks())
out:
---------------------ksv in long string
[Match(a=3, b=226, size=0)]
-----------------------start with ksv
[Match(a=0, b=0, size=3), Match(a=3, b=225, size=0)]
-----------------------ksv in short string
[Match(a=0, b=1, size=3), Match(a=3, b=59, size=0)]
obviously, for the first match_result,'gks' is in temp, but get_matching_blocks didn't return the block.
then I delete the first 'g' of the temp, it returned the right block.
and i try make the temp shorter and still not start with 'gks', it also returned the right block.
so i'm confused. why the first try didn't succeed?