import datetime
import time
curr_time = datetime.datetime.now()
timestampyear = curr_time.year#年
timestampmonth = curr_time.month#月
timestampday = curr_time.day#日
timestamphour = curr_time.hour#时
timestampminute = curr_time.minute#分
timestampsecond = curr_time.second#秒
t = time.time()#毫秒
timestampmm=int(round(t * 1000))
timestring=str(timestampyear)+str(timestampmonth)+str(timestampday)+str(timestamphour)+str(timestampminute)+str(timestampsecond)+str(timestampmm)
print(timestring)
#print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) )#无毫秒
#print(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f'))#毫秒
python时间戳
于 2023-07-03 17:37:46 首次发布