gpt4 book ai didi

python - 使用Python : How can I convert given UT time to LST time Such that the function automatically increments day after 24 Hr check

转载 作者:太空宇宙 更新时间:2023-11-03 20:49:52 26 4
gpt4 key购买 nike

我想将给定的世界时间 (UT) 转换为本地时间 (LT)。这样该函数就会在 24 小时检查后自动增加天数。我尝试了各种代码。我成功转换了时间,但无法在循环中将其增加一定的持续时间。

最佳答案

尝试下面的代码:

>>> from datetime import datetime
>>> import pytz
>>> dt = datetime.utcnow()
>>> dt.astimezone(pytz.timezone('Europe/Paris'))
datetime.datetime(2019, 5, 28, 4, 44, 12, 778393, tzinfo=<DstTzInfo 'Europe/Paris' CEST+2:00:00 DST>)
>>> print(dt.astimezone(pytz.timezone('Europe/Paris')))
2019-05-28 04:44:12.778393+02:00
>>>

关于python - 使用Python : How can I convert given UT time to LST time Such that the function automatically increments day after 24 Hr check,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56340255/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com