用python获取当前时间和日期
作者:互联网
import time
t1=time.time() #表示从1970年到现在过了多少秒
print('t1:',t1)
t2=time.localtime(time.time())
print('t2:',t2)
t3=time.asctime(time.localtime(time.time()))
print('t3:'+t3)
t4=time.strftime("当前日期:%Y年%m月%d日",time.localtime(time.time()))
print('t4:'+t4)
t5=time.strftime("当前时间:%H时%M分%S秒",time.localtime(time.time()))
print('t5:'+t5)
t6=time.strftime("当前日期:%Y-%m-%d",time.localtime(time.time()))
print('t6:'+t6)
t7=time.strftime("当前时间:%H-%M-%S",time.localtime(time.time()))
print('t7:'+t7)
标签:-%,python,获取,日期,time,print,t6,strftime,localtime 来源: https://blog.csdn.net/qq_50866711/article/details/116919958