Python datetime module current time in HR:MIN:SEC

2019-09-21 05:46发布

It seems like i should be able to find some sort of documentation on this, but everything im finding isnt working. In Python (v. 3.3) how do you get the current time in HR:MIN:SEC format using the datetime module?

标签: python time
1条回答
forever°为你锁心
2楼-- · 2019-09-21 05:59

This should do it:

import datetime

now = datetime.datetime.now()
now.strftime('%H:%M:%S')

Other units of time can be found by using the directives found here.

查看更多
登录 后发表回答