擅长:python、mysql、java
<p>重置<code>now</code>的次数太多:</p>
<pre><code>while True:
now = datetime.datetime.now()
while True: # keep the 'now' until one second ticked by:
if now.second != datetime.datetime.now().second:
print(now)
time.sleep(0.1)
else:
break # get the next now ...
</code></pre>
<p>你得到任何输出都是运气。。。。第二个必须在</p>
<blockquote>
<pre><code>now = datetime.datetime.now() # this line
if now.second != datetime.datetime.now().second: # and this line
</code></pre>
</blockquote>