another-world

time库

import time

1)time库的time方法

  # 当前 秒数时间
  import time
  time.time()

2)time库的localtime方法

作用:秒数时间--->struct_time对象
参数:秒数,默认当前秒数时间
返回:struct_time对象

3)time库的strftime方法

作用:struct_time对象---->字符串
参数1:指定 返回的字符串 的格式
参数2:待转换的 struct_time对象

  time.strftime(\'%Y-%m-%d\', time.localtime())


time库 总结:

关键词: struct_time对象

秒数--------.localtime()----------->struct_time对象----------.strftime()---------->字符串

  import time

  # 当前秒数时间
  seconds = time.time()

  # 秒数时间 转换为  struct_time对象
  structtime = time.localtime(seconds)

  # struct_time对象  转换为  字符串(日期时间)
  strf = \'%Y-%m-%d %H:%M:%S\'
  strtime = time.strftime(strf, structtime)    # 2020-11-20 15:18:54

datetime库

分类:

技术点:

相关文章:

  • 2022-02-21
  • 2021-12-11
  • 2021-05-21
  • 2021-06-06
  • 2021-11-18
  • 2021-09-09
猜你喜欢
  • 2021-05-23
  • 2021-08-10
  • 2022-02-25
  • 2021-11-17
  • 2022-01-16
  • 2021-09-26
  • 2021-11-15
相关资源
相似解决方案