使用 timedelta 即可,如下:


from datetime import datetime as dt, timedelta

yesterday = (dt.today() - timedelta(days=1)).strftime('%Y-%m-%d')