我有一些字符串这样的:获取所有两个特定单词之间的词在python
The pizza is so hot
Today I bought an hot and tasty pizza
我需要提取比萨饼和形容词在python 热之间的所有的话。我能怎么做??
这些是输出的一个例子。
is so
and tasty
请大家记住,属性(比萨饼为例)和形容词(热例如)可能是一个多令牌字。
这就是我想:
attribute = re.search(values[0], descrizione, re.IGNORECASE)
value = re.search(names[0], descrizione, re.IGNORECASE)
if (attribute):
print (attribute.group())
print (descrizione.find(attribute.group()))
if (value):
print (value.group())
print (descrizione.find(value.group()))
比萨饼和热可以出现多次排队?它应该如何处理? –
@BrendanAbel no。他们不能:D –
你是否需要找到多个字符串中的单词,或者只是两个字符? – NBartley