擅长:python、mysql、java
<p>pythonscsv模块是一个很好的库,但是经常使用它来完成更简单的任务可能会有点过头。
对我来说,这是一个典型的例子,使用csv模块可能会使事情过于复杂</p>
<p>对我来说</p>
<ul>
<li>只是在文件中迭代</li>
<li>以逗号分隔每行,并提取第一个拆分</li>
<li>然后在空白处分割剩余部分</li>
<li>将每个单词转换为小写</li>
<li>去掉所有的标点和数字</li>
<li>把结果理解为一个集合</li>
</ul>
<p>是一种线性的直接方法</p>
<p>使用以下文件内容运行的示例</p>
<pre class="lang-none prettyprint-override"><code>Lorem Ipsum is simply dummy "text" of the ,0
printing and typesetting; industry. Lorem,1
Ipsum has been the industry's standard ,2
dummy text ever since the 1500s, when an,3
unknown printer took a galley of type and,4
scrambled it to make a type specimen ,5
book. It has survived not only five ,6
centuries, but also the leap into electronic,7
typesetting, remaining essentially unch,8
anged. It was popularised in the 1960s with ,9
the release of Letraset sheets conta,10
ining Lorem Ipsum passages, and more rec,11
ently with desktop publishing software like,12
!!Aldus PageMaker!! including versions of,13
Lorem Ipsum.,14
</code></pre>
<hr/>
^{pr2}$