好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

python strftime获取当前时间

说明

1、通过strptime()函数,可以获得与单一日期相关的数据。

2、strftime()函数的第二个参数接受struct_time对象。将秒数转换为标准时间。如果没有参数,回到现在的时间。 time.localtime()的作用是将格式时间戳作为当地时间,具有sec参数,即对应的time.time()函数的秒数,

实例

import time
 
s = time.strftime("%H:%M:%S", time.localtime())
print(s)

以上就是python strftime获取当前时间,希望对大家有所帮助。 更多Python学习指路: python基础教程

本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。

查看更多关于python strftime获取当前时间的详细内容...

  阅读:16次