Python datetime 与 time 模块之间的区别 [英] Difference between Python datetime vs time modules

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

问题描述

我想弄清楚 datetimetime 模块之间的区别,以及每个模块的用途.

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 datetime 与 time 模块之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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