擅长:python、mysql、java
<p>您只对<code>now</code>进行了一次采样,您需要在for循环中这样做</p>
<pre><code>from datetime import datetime
now = datetime.now()
print("%02d-%02d-%04d") % (now.year, now.month, now.day)
#below is the loop
for i in range(0, 100):
time.sleep(1)
now = datetime.now()
print ("%02d:%02d:%02d") % (now.hour, now.minute, now.second)
</code></pre>