擅长:python、mysql、java
<p>你可以试试这个</p>
<pre><code>for data in soup.find_all('b', {'class' : 'tur highlight'}):
if word == '\n' and data.get_text() == '\n':
pass
else:
write.writerow([word, data.get_text()])
</code></pre>
<p>或者你可以用</p>
<pre><code>with open('test_csv.csv','w',newline='') as file:
</code></pre>
<p>对于python 3</p>
<p>以及</p>
<pre><code>with open('test_csv.csv','wb') as file:
</code></pre>
<p>对于Python2</p>