擅长:python、mysql、java
<p>您可以使用:</p>
<pre><code>datetime.date.fromordinal(datetime.date.today().toordinal()-1)
</code></pre>
<p><a href="https://stackoverflow.com/questions/15344710/get-yesterdays-date-in-python-dst-safe">Get yesterday's date in Python, DST-safe</a></p>
<p>这将有助于格式化:</p>
<p><a href="http://www.cyberciti.biz/faq/howto-get-current-date-time-in-python/" rel="nofollow noreferrer">http://www.cyberciti.biz/faq/howto-get-current-date-time-in-python/</a></p>