擅长:python、mysql、java
<p>有一个更好的方法可以做到这一点,但希望在进入会议前发布:)</p>
<p>首先,逻辑如下
1) 遍历列表中的每个元素
2) 把这句话分成两部分
3) 把句子中的每个单词循环一遍,检查是否有数学题
4) 如果匹配,则更新索引</p>
<p>假设a是一本字典</p>
<pre><code>for line in a:
sentence = line.split()
for word in sentence:
if word == 'Hey':
# Found an index which contains the word so update the index here
a[line] = 'New value for index'
</code></pre>