#!/usr/bin/python3 # -*- coding: UTF-8 -*- import datetime import time #时间戳 ticks=time.time() print(ticks) #结构体时间{tm_year...} localtime=time.localtime(ticks) print(localtime) #格式化时间 strftime=time.asctime(localtime) print(strftime) #获取当前日期和时间 current_datetime=datetime.datetime.now() print(current_datetime) #获取当前日期 current_date=datetime.date.today() print(current_date) #格式化日期 formatted_datatime=current_datetime.strftime("%Y-%m-%d %H:%M:%S") print(formatted_datatime)
标签:python,ticks,datetime,current,日期,time,print,localtime From: https://www.cnblogs.com/ho966/p/17847920.html