from datetime import timedelta, datetime yesterday = datetime.today()+timedelta(-1) yesterday_format = yesterday.strftime('%Y-%m-%d') print('昨天是:%s' %yesterday_format)