版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u013421629/article/details/82744099
import datetime
def getToday():
"""
:return: 获取今天日期
"""
today = datetime.date.today()
# 日期转字符串
record_date=today.strftime('%Y-%m-%d')
return record_date
def getYesterday():
"""
:return: 获取昨天日期
"""
today = datetime.date.today()
oneday=datetime.timedelta(days=1)
yesterday=today-oneday
# 日期转字符串
partition_date=yesterday.strftime('%Y-%m-%d')
return partition_date
today=getToday()
print(today)
partition_date=getYesterday()
print(partition_date)
2018-09-17
2018-09-16
Process finished with exit code 0