python字符串操作bianchrngti_Python字符串操作

import difflib

str1 = "Poor Impulse Control: A Good Babysitter Is Hard To Find"

str2 = """ A Good Babysitter Is Hard To Find This is Frederick

by Leo Lionni, the first book I picked for myself.

I was in kindergarten, I believe, which would be either 1968 or 1969.

Frederick has a specific lesson for children about how art is as

important in life as bread, but there's a secondary consideration

I took away: if we pool our talents our lives are immeasurably better.

Curiously, this book is the story of my life, however one interprets

those things. I expect Mickey Rooney to show up any time with a barn

and a plan for a show, though my mom is not making costumes. My sisters

own a toy store with a fantastic selection of imaginative children's books.

I try not to open them because I can't close them and put them back.

My tantrums are setting a bad example for the kids. Anyway, I mention

this because yesterday was Mr. Rogers' 40th anniversary. I appreciate

the peaceful gentleman more as time passes, as I play with finger puppets

in department meetings, as I eye hollow trees for Lady Elaine Fairchild

infestations. Maybe Pete can build me trolley tracks!Labels: To Take

Your Heart Away """

s = difflib.SequenceMatcher(None, str1, str2)

print len(str1), len(str2)

star_a, start_b, length = s.find_longest_match(0, len(str1)-1, 0, len(str2)-1)

print star_a, start_b, length

print str1[star_a:star_a + length]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值