方法一:
import time
print time.strftime("%Y-%m-%d") #输出当前日期 2018-04-26
方法二:
import datetime
print datetime.datetime.now().strftime("%y-%m-%d %H:%M:%S") #输出当前日期 2018-04-26
import datetime
today = datetime.date.today()
tomorrow = today + datetime.timedelta(days=1) #days参数1是明天,-1即是昨天。
print tomorrow
import datetime
today = datetime.date.today()
first = today.replace(day=1)
last_month = first - datetime.timedelta(days=1)
print(last_month.strftime("%Y%m"))