Python 函数 datetime.now() 和 datetime.today() 之间有什么区别?

pythonserver side programmingprogramming

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

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


相关文章


有用资源