1、格式化时间time.strftime,返回字符串
import time
time.strftime('%Y-%m-%d %H:%M:%S')
2、时间差 timedelta
from datetime import datetime,timedelta
date_time = datetime.now()-timedelta(days=2)
date_time = date_time.strftime('%Y%m%d%H%M%S')
2024-04-10 19:35:44
1、格式化时间time.strftime,返回字符串
import time
time.strftime('%Y-%m-%d %H:%M:%S')
2、时间差 timedelta
from datetime import datetime,timedelta
date_time = datetime.now()-timedelta(days=2)
date_time = date_time.strftime('%Y%m%d%H%M%S')
下一篇:JAVA之数据溢出