<p>给予</p>
<pre><code>keywords=[
"i can help you with that",
"i can surely help you with that",
"i can check and help you with that",
"i will be more than happy to help you",
"let me assist you on this",
"to assist you better"
]
col1 = [
"agent enters(as arrin)",
"",
"I'll be happy to assist you. Give me a moment to review your request.",
"I see that the light in your Modem is Blinking Red. Am I right ?",
"Thank you for the detailed information.",
"Please do not worry.",
"Don't worry johny. I can help you with that.",
"Let me connect this chat to the concern team to help you out with this, Please stay connected."
]
col2 = [
'2018-10-14 21:16:58',
'2018-10-14 21:17:00',
'2018-10-14 21:17:40',
'2018-10-14 21:18:25',
'2018-10-14 21:19:39',
'2018-10-14 21:19:43',
'2018-10-14 21:21:04',
'2018-10-14 21:22:00'
]
</code></pre>
<p>您可以运行:</p>
<pre><code>for i, col in enumerate(col1):
if any([keyword in col for keyword in keywords]):
print(col2[i])
</code></pre>
<p><code>any</code>使您能够简洁地测试字符串中是否出现<strong>任何<strong>关键字</p>
<p>根据需要,您可能希望在搜索之前将字符串转换为小写,或者在<code>for-loop</code>中执行类似于以下操作:</p>
<pre><code>for i, col in enumerate(col1):
if any([keyword.lower() in col.lower() for keyword in keywords]):
print(col2[i])
</code></pre>