我正在按照教程来识别和打印特定字符串之间的单词;
f
是字符串Mango grapes Lemon Ginger Pineapple
def findFruit(f):
global fruit
found = [re.search(r'(.*?) (Lemon) (.*?)$', word) for word in f]
for i in found:
if i is not None:
fruit = i.group(1)
fruit = i.group(3)
grapes
并将Ginger
在我打印时输出fruit
。但是我希望输出看起来像"grapes" # "Ginger"
(注意""
和#
符号)。