擅长:python、mysql、java
<p>嘿,我已经在Python2.7(mac)上试过了,因为我有那个版本,所以试着掌握逻辑</p>
<pre><code>from collections import Counter
mysentence = """As far as the laws of mathematics refer to reality they are not certain as far as they are certain they do not refer to reality"""
mysentence = dict(Counter(mysentence.split()))
for i in sorted(mysentence.keys()):
print ('"'+i+'" is repeated '+str(mysentence[i])+' time.')
</code></pre>
<p>我希望这是你正在寻找的,如果没有,然后打电话给我高兴地学习新的东西。</p>
<pre><code>"As" is repeated 1 time.
"are" is repeated 2 time.
"as" is repeated 3 time.
"certain" is repeated 2 time.
"do" is repeated 1 time.
"far" is repeated 2 time.
"laws" is repeated 1 time.
"mathematics" is repeated 1 time.
"not" is repeated 2 time.
"of" is repeated 1 time.
"reality" is repeated 2 time.
"refer" is repeated 2 time.
"the" is repeated 1 time.
"they" is repeated 3 time.
"to" is repeated 2 time.
</code></pre>