跳转至

115

本文总阅读量次 ,原创教程,严禁转载
@author jackzhenguo
@desc 
@date 2019/10/15

115 获取当前时间

from datetime import date, datetime
from time import localtime, strftime

today_date = date.today()
print(today_date)  # 2019-12-22

today_time = datetime.today()
print(today_time)  # 2019-12-22 18:02:33.398894

local_time = localtime()
print(strftime("%Y-%m-%d %H:%M:%S", local_time))  # 转化为定制的格式 2019-12-22 18:13:41

上一个例子 下一个例子