1、字符串转datetime
from datetime import datetime, timedelta time_a = datetime.strptime('2022-09-03 20:31:10', "%Y-%m-%d %H:%M:%S")
2、datetime转字符串
str_time_a = time_a.strftime("%Y-%m-%d")
输出
2022-09-03 20:31:10 2022-09-03
标签:-%,03,Python,09,datetime,转化,时间,2022,time From: https://www.cnblogs.com/irobotzz/p/16745705.html