擅长:python、mysql、java
<p>它第一次工作是因为<code>tomorrow</code>是一个<code>datetime.datetime</code>实例,然后:</p>
<pre><code>tomorrow = datetime.datetime.now()
</code></pre>
<p>但是,在第一次之后,用字符串替换<code>tomorrow</code>:</p>
<pre><code>tomorrow = tomorrow.strftime('%d/%m/%Y')
</code></pre>
<p>不能将<code>timedelta()</code>对象添加到字符串。不要重新绑定<code>tomorrow</code>。将字符串指定给其他名称,或仅格式化要打印的对象(而不将其指定给名称):</p>
<pre><code>if hour >= 23:
tomorrow = tomorrow + datetime.timedelta(days=1)
tomorrow_formatted = tomorrow.strftime('%d/%m/%Y')
hour = 9
print(tomorrow_formatted) # different name
print(tomorrow.strftime('%d/%m/%Y')) # print the `strftime()` result
</code></pre>