from datetime import datetime, timedelta
push_time = '2022-03-23T08:40:10.895Z'
push_time1 = datetime.strptime(push_time[0:-5], "%Y-%m-%dT%H:%M:%S") + timedelta(hours=8)
print(push_time1)
push_time2 = datetime.strptime(push_time, "%Y-%m-%dT%H:%M:%S.%fZ") + timedelta(hours=8)
print(push_time2)
输出为
2022-03-23 16:40:10
2022-03-23 16:40:10.895000
如果只想显示为某天
>>> time3=push_time1.strftime('%F')
>>> time3
'2022-03-23'
标签:-%,UTC,03,23,datetime,push,2022,字符串,格式
From: https://www.cnblogs.com/regit/p/16969507.html