题目:
将unix时间戳转换成格式化日期?
思路:
1、模块datetime.datetime.fromtimestamp()
2、模块.strftime()
结果:
import datetime
unix_time = 1668834935.652549
datetime_obj = datetime.datetime.fromtimestamp(unix_time)
datetime_str = datetime_obj.strftime("%Y-%m-%d %H:%M:%S")
print(datetime_str)
-------------------
2022-11-19 13:15:35
标签:-%,转换成,格式化,datetime,unix,obj,34 From: https://www.cnblogs.com/LoLong/p/16905941.html