Skip to content

Latest commit

 

History

History
23 lines (17 loc) · 510 Bytes

115.md

File metadata and controls

23 lines (17 loc) · 510 Bytes
@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
[上一个例子](114.md) [下一个例子](116.md)