python 时间戳

import time

print(time.strftime("%Y%m%d %H:%M:%S"))

直接打印

import time
def time_str():
    fmt = "%Y%m%d %H:%M:%S"  # 定义时间显示格式
    Date = time.strftime(fmt)
    print(Date )
time_str()

封装为函数

posted @ 2021-06-13 21:02  阿瑶丫  阅读(113)  评论(0)    收藏  举报