zl程序教程

您现在的位置是:首页 >  后端

当前栏目

[Work Summary] Python获取当前年月日时分秒

Python 获取 当前 work Summary 年月日 时分秒
2023-09-11 14:22:53 时间
美图欣赏2022/08/09

Python获取当前时间

import time
# 2022-08-09 16:43:35
now_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())

 Python获取当前时间的年月日时分秒

import datetime
# datetime.datetime(2022, 8, 9, 16, 45, 22)
today = datetime.datetime.today()
# 2022
currentYear = today.year
# 8
currentMonth = today.month
# 9
currentDay = today.day
# 16
currentHour = today.hour
# 45
currentMinute = today.minute
# 22
currentSecond = today.second