擅长:python、mysql、java
<p>你可以用线程模块来做</p>
<pre><code>>>> import threading
>>> END = False
>>> def run(x=0):
... x += 5
... print x
... if not END:
... threading.Timer(1.0, run, [x]).start()
...
>>> threading.Timer(1.0, run, [x]).start()
>>> 5
10
15
20
25
30
35
40
</code></pre>
<p>然后,当您希望它停止时,设置<code>END = True</code>。在</p>