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