python返回时间带有gmt_在python中将GMT时间转换为本地时间

它们描述了库函数^{}tz=None^{},这可能正是您想要的。在Return a datetime object with new tzinfo attribute tz, adjusting the date and time data so the result is the same UTC time as self, but in tz‘s local time.

它们有示例代码,用于根据与UTC的偏移量定义时区,并以如下声明结尾:Pacific = USTimeZone(-8, "Pacific", "PST", "PDT")

读了之后,你的问题是什么?在

你有date还是datetime?i、 e.数据有时区成分吗?如果没有时间成分,那么将日期更改为不同的时区意味着什么?在

你有“天真”还是“有意识”datetime?从文件上看An aware object has sufficient knowledge of applicable algorithmic and political time adjustments, such as time zone and daylight saving time information, to locate itself relative to other aware objects. An aware object is used to represent a specific moment in time that is not open to interpretation....

A naive object does not contain enough information to unambiguously locate itself relative to other date/time objects. Whether a naive object represents Coordinated Universal Time (UTC), local time, or time in some other timezone is purely up to the program, just like it is up to the program whether a particular number represents metres, miles, or mass. Naive objects are easy to understand and to work with, at the cost of ignoring some aspects of reality.

Python文档非常好。也许它可以回答你的问题而不必问StackOverflow。在

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值