python的time库

time库

1.定义

  • time库是python中处理时间的标准库

2. time库的使用

  • 时间获取-------time() ctime() gmtime()
  • 时间格式化-------strftime()  strptime()
  • 程序计时-------sleep()  perf_counter()

3.时间获取函数

  • time()-------获取当前时间戳,浮点数形式
  • ctime()-------以可读的方式返回字符串时间

         

  • gmtime()-------计算机可以处理的时间格式

        

 

4.时间格式化

  • strftime()-------将时间进行合理输出

          

  • strptime()-------自定义时间

5.程序计时

  • perf_counter()-------测量时间函数

         

  • sleep()-------产生时间函数,s拟休眠的时间,单位是秒,可以是浮点数

          

 

你可能感兴趣的:(python)