ctime使用及datetime简单使用

from time import ctime,sleep
def Clock(func):
    def clock():
        print("现在是:",ctime())
        func()
        sleep(3)
        print("现在是:",ctime())
    return clock

@Clock
def func():
    print("函数计时")
func()

import datetime
now = datetime.datetime.now()#获取当前时间
str = "%s"%(now.strftime("%Y-%m-%d-%H-%M-%S"))
"""
Y 年 y
m 月
d 号 
H 时
M 分
S 秒
"""
# 设置时间格式
print(str)

2020-05-08

原文地址:https://www.cnblogs.com/hany-postq473111315/p/12846876.html