zoukankan      html  css  js  c++  java
  • 016时间模块

    #有‘*’为重点
    import  time
    print(time.time())#以秒的形式返回******

    time.sleep(3)      ******
    print(time.clock())     #cpu执行的时间

    print(time.gmtime()) # 结构化时间,本初子午线那里的时间time.struct_time(tm_year=2017,tm_mon=12,tm_mday=26,tm_hour=16,tm_min=45,tm_sec=47,tm_wday=1,tm_yday=360,tm_isdst=0)     我执行的时间是2017.12.27  00:47,打印的时间是12月26日

    print(time.localtime()) # 本地时间time.struct_time(tm_year=2017,tm_mon=12,tm_mday=27,tm_hour=0,tm_min=52,tm_sec=29,tm_wday=2,tm_yday=361,tm_isdst=0)             ******

    struct_time=time.localtime()
    print(time.strftime('%Y/%m/%d%H:%M:%S',struct_time))   # 2017/12/2711:12:47           ******结构化时间转化成字符串时间
    print(time.strptime(str_time,'%Y/%m/%d%H:%M:%S'))       # 字符串时间转化成结构化时间
    a=time.strptime(str_time,'%Y/%m/%d%H:%M:%S')              #结构化时间用于取分别的数据
    print(a.tm_year,  a.tm_wday)

    print(time.ctime())  # Wed  Dec  27  11:22:28  2017
    print(time.mktime(struct_time))        #  1514345205.0 转化成时间戳  


    import   datetime
    print(datetime.datetime.now())   #  2017-12-27  11:29:47.491757

  • 相关阅读:
    C#连接MySQL
    国双面试题
    Redis入门安装配置
    vs2013密钥
    单例模式
    用R画韦恩图
    Snipaste截图
    秩和检验
    用R包中heatmap画热图
    OTU(operational taxonomic units),即操作分类单元
  • 原文地址:https://www.cnblogs.com/-nbloser/p/8127874.html
Copyright © 2011-2022 走看看