python培训之strftime获取当前时间

发布时间:2023-03-03 09:35:43 人气:29 作者:多测师

  python strftime获取当前时间

  说明

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

python培训之strftime获取当前时间

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

  实例

  import time

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

  print(s)

  以上就是python strftime获取当前时间,希望对大家有所帮助。更多Python学习指路:请关注多测师。https://www.e70w.com/xwzx/


返回列表
在线客服
联系方式

热线电话

17727591462

上班时间

周一到周五

二维码
线