<p>我有文件包含</p>
<pre><code>google
google talk browser
google talks
google talk
</code></pre>
<p>如何使用python搜索文件中的“talks”,并且在不使用额外字符串的情况下精确搜索并使用python打印行</p>
<pre><code>import re
txt = open("youfile.txt").read()
if re.search(r'[^\s]?google talk[\s$]?',txt):
//code for string present
else:
//code for string not-present
</code></pre>