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()

封装为函数

原文地址:https://www.cnblogs.com/nuliyao123/p/14881193.html