zoukankan      html  css  js  c++  java
  • python标准库之time库

    time库是python处理时间数据的标准库

    time库有3种时间表现方式:

    time库主要提供3类属性:

    1、time库时间获取属性:

    gmtime与localtimex,ctime与 asctime的比较

    不同的是:

    gmtime 返回的是 电脑时间的格林威治时间,也就是0时区的时间, localtime 返回的是 电脑时间

    ctime接收浮点数形式的时间格式,asctiem接收元组时间格式

    相同的是:

    两者返回的时间格式都是元组形式

    两者返回的都是字符串形式的时间格式

     time库格式化属性:

    time.strftiem(formt, tuple)  #其作用是将struc_time转换为模板格式的字符串时间,易于阅读。

    format 表示模板格式如 "%Y-%m-%d %H:%M:%S" ,tuple 表示 struct_time。

    time.strptiem(str, format)  # 将字符串形式的时间转换为stuct_time

     

    3、程序计时类属性

    推荐使用per_counter、process_time精度较高:

    两者区别:

    perf_counter: 含起始和终止的所有时间,包含sleep时间

    process_time: 不含进程sleep时间。

  • 相关阅读:
    SpringBoot 拦截器
    SpringBoot学习笔记1
    mysql学习1
    mybatis运行原理学习
    js学习2
    设计原则
    mybatis学习1
    spring mvc
    Jenkins流水线部署maven不同模块服务到不同服务器运行
    L2Dwidget让自己的vue项目骚起来
  • 原文地址:https://www.cnblogs.com/a666/p/9640699.html
Copyright © 2011-2022 走看看