gpt4 book ai didi

python - 将时间戳从 tz ='UTC' 更改为 tz ='tzutc()'

转载 作者:行者123 更新时间:2023-12-01 00:26:29 31 4
gpt4 key购买 nike

我有一个来自 API 调用的系列,它为我提供了以下格式的索引

timeseries.index.values[0]

>>> Timestamp('2019-10-25 15:33:26.068569856+0000', tz='tzutc()')

然后我附加一些带有时间戳的数据:datetime.utcnow().replace(tzinfo=pytz.UTC),遗憾的是,它有另一种格式

timeseries.index.values[-1]

>>> Timestamp('2019-10-25 15:33:27.388853+0000', tz='UTC')]

这会导致一些错误。如何创建原始格式的时间戳 (tz='tzutc())?

最佳答案

from datetime import datetime
from dateutil.tz import *

datetime.now(tzutc())

关于python - 将时间戳从 tz ='UTC' 更改为 tz ='tzutc()',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58561661/

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