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

posted @ 2020-05-08 00:24  Hany47315  阅读(565)  评论(0)    收藏  举报