Imr*_*fin -1 python performance time
import time
word = {"success":0, "desire":0, "effort":0, ...}
def cleaner(x):
dust = ",./<>?;''[]{}\=+_)(*&^%$#@!`~"
for letter in x:
if letter in dust:
x = x[0:x.index(letter)]+x[x.index(letter)+1:]
else:
pass
return x #alhamdlillah it worked 31.07.12
print "input text to analyze"
itext = cleaner(raw_input()).split()
t = time.clock()
for iword in itext:
if iword in word:
word[iword] += 1
else:
pass
print t
print len(itext)
Run Code Online (Sandbox Code Playgroud)
每次我调用代码,t都会增加.任何人都可以解释这背后的基本概念/原因.也许在系统过程方面?非常感谢,编程小伙子们.
归档时间: |
|
查看次数: |
294 次 |
最近记录: |