1

我试图弄清楚如何做到这一点:

>>>sentence = "There's something right there."
>>>change_s(sentence)
['there', 'his', 'something', 'right', 'there.']
>>>sentence = "it's Patrick's car."
>>>change_s(sentence)
['it', 'his', 'Patrick', 'his', 'car.']

所以基本上我想将“'s”更改为“his”(即使它在语法上不正确)并将这些单词放在一个列表中。

4

1 回答 1

1
In [6]: sentence = "There's something right there."

In [7]: sentence.replace("'s", " his").split()
Out[7]: ['There', 'his', 'something', 'right', 'there.']
于 2012-11-27T20:08:14.923 回答