Python日期时间与时间模块之间的差异 [英] Difference between Python datetime vs time modules

查看:75
本文介绍了Python日期时间与时间模块之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图弄清楚 datetime time 模块之间的区别,以及分别应使用的模块

I am trying to figure out the differences between the datetime and time modules, and what each should be used for.

我知道 datetime 同时提供了日期和时间。 time 模块的用途是什么?

I know that datetime provides both dates and time. What is the use of the time module?

示例将不胜枚举,时区差异尤其令人关注。

Examples would be appreciated and differences concerning timezones would especially be of interest.

推荐答案

time 模块主要用于处理unix时间戳;表示为一个浮点数,以距unix纪元的秒数​​为单位。 datetime 模块可以支持许多相同的操作,但是提供了更多的面向对象的类型集,并且对时区的支持有限。

the time module is principally for working with unix time stamps; expressed as a floating point number taken to be seconds since the unix epoch. the datetime module can support many of the same operations, but provides a more object oriented set of types, and also has some limited support for time zones.

这篇关于Python日期时间与时间模块之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆