擅长:python、mysql、java
<p>我想这是你的例外</p>
<p>代码:</p>
<pre><code>strings = [
'investmentproperty',
'investmentsomethingproperty',
'investmentsomethingelseproperty',
'abcinvestmentproperty',
'investmentabcproperty'
]
words = [
'investment',
'property',
'something',
'else'
]
new_words =filter(lambda x: [x for i in words if x in i and x != i] == [], words)
res = list()
for string in strings:
len_string = len(string)
in_words = []
for w in new_words:
if w in string:
in_words.append(w)
if len(''.join(in_words)) == len_string:
res.append(string)
print res
</code></pre>
<p>输出:</p>
<pre><code>['investmentproperty', 'investmentsomethingproperty', 'investmentsomethingelseproperty']
</code></pre>