擅长:python、mysql、java
<p>这是因为当您定义函数datetime.now()时,仅在该时间计算该值,并且该值存储在currentTime中,因此无论何时运行<em>fun1</em>currentTime值都不会更新。<br/>
您只需在<strong>TimeHelper.py中执行此操作即可</p>
<pre class="lang-py prettyprint-override"><code>from datetime import datetime
def fun1(currentTime=None):
if currentTime:
print(currentTime)
else:
print(datetime.now())
</code></pre>
<p>希望有帮助:)</p>