Use:
(使用:)
>>> import datetime
>>> datetime.datetime.now()
datetime.datetime(2009, 1, 6, 15, 8, 24, 78915)
>>> print(datetime.datetime.now())
2009-01-06 15:08:24.789150
And just the time:
(而只是时间:)
>>> datetime.datetime.now().time()
datetime.time(15, 8, 24, 78915)
>>> print(datetime.datetime.now().time())
15:08:24.789150
See the documentation for more information.
(请参阅文档以获取更多信息。)
To save typing, you can import the datetime
object from the datetime
module:
(要保存类型,可以从datetime
模块导入datetime
对象:)
>>> from datetime import datetime
Then remove the leading datetime.
(然后删除前导datetime.
)
from all of the above. (以上所有。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…