我有一个句子和一个子字符串列表。如何检查该句子中是否出现了确切的子字符串?
例如:
Credit card customers will be allowed interest-free installment plans for all school fee payments as well as grocery purchases with no processing fees for up to six months.
现在我有了一个单词列表
["credit card customers","school fee payment","six months"].
如何检查以上字符串中是否存在这些子字符串?
这是您的意思吗?
string = 'Credit card customers will be allowed interest-free installment plans for all school fee payments as well as grocery purchases with no processing fees for up to six months.'
listing = ["credit card customers","school fee payment","six months"]
def adj_or_not(index1,index2):
if listing[index1] + listing[index2] in string:
return True
else:
return False
adj_or_not(0,1)
输出:
False