【发布时间】:2021-10-10 10:05:45
【问题描述】:
如何在 python 中将此天真的时间更改为 UTC 时间
时间是2021-08-05T08:32:47.362000Z
st= "2021-08-05T08:32:47.362000Z"
dt = datetime.strptime(st,"%Y-%m-%d %H:%M:%S.%fZ")
我不知道如何在python中解析这个时间。上面给出的代码是我知道我这次不知道解析的。
所以这个时间是从 Django 数据库中获取的,我插入的是 UTC 时间,结果得到了上述时间。
问题是我需要获取 UTC 时间。
【问题讨论】:
-
your other question 也已回答(日期/时间字符串中的“T”除外)。
-
请澄清your earlier question 也没有涵盖这一点。从外观上看,唯一的“问题”是用预期格式的 T 替换空格。
标签: python python-3.x date datetime time