擅长:python、mysql、java
<p>此代码:</p>
<pre><code>from collections import Counter
data = open( 'Test1.txt' ).read() # read the file
data = ''.join( [i.upper() if i.isalpha() else ' ' for i in data] ) # remove the punctuation
c = Counter( data.split() ) # count the words
c.most_common()
</code></pre>
<p>印刷品:</p>
<pre><code>[('A', 2), ('CHUCK', 2), ('WOODCHUCK', 2), ('WOOD', 2), ('WOULD', 1), ('COULD', 1), ('HOW', 1), ('MUCH', 1), ('IF', 1)]
</code></pre>
<p>我想知道代码是不是太短了?=)</p>