【发布时间】:2016-03-11 12:27:55
【问题描述】:
我想用 Python 构建一个脚本,它接受一个基本字符串并通过其他字符串列表运行它。该脚本应返回字符串中但不在基本字符串中的单词或短语的列表。
例子:
string = 'why kid is upset'
list_of_strings = ['why my kid is upset', 'why beautiful kid is upset',
'why my 15 years old kid is upset', 'why my kid is always upset']
应该返回
['my', 'beautiful', 'my 15 years old', 'always']
你会建议我研究什么库来解决这个问题?
【问题讨论】:
-
为什么你的结果列表的最后一项不是
'my always'?
标签: python python-3.x