Python 函数 datetime.now() 与 datetime.today() 有什么区别?


datetime.now() 函数将 tzinfo 作为关键字参数,但 datetime.today() 不接受任何关键字参数。引用文档 −

datetime.now() 返回当前的本地时间和日期。如果可选项 tz 为 None 或未指定,则这相当于 today(),但如果可能,比通过 time.time() 时间戳获得的精度更高(例如,在提供 C gettimeofday() 函数的平台上,这可能会实现)。

更新于: 2020-06-13

1K+ 查看次数

启动您的 职业生涯

通过完成课程获得认证

开始
广告
© . All rights reserved.