zoukankan      html  css  js  c++  java
  • Python time

    #time模块
    import time
    
    #print(time.time())  #1518082617.222511   *****
    # 该数值为1970年unix诞生到现在的秒数  为时间戳
    #time.sleep(3)        #后边程序在3秒后执行  *****
    #print(time.clock())   #计算cpu执行时间
    #print(time.gmtime())  #结构化时间:time.struct_time(tm_year=2018, tm_mon=2, tm_mday=8,
    #  tm_hour=9, tm_min=44, tm_sec=19, tm_wday=3, tm_yday=39, tm_isdst=0)
    #print(time.localtime()) #结构化时间(北京):time.struct_time(tm_year=2018, tm_mon=2, tm_mday=8,
    # tm_hour=17, tm_min=55, tm_sec=9, tm_wday=3, tm_yday=39, tm_isdst=0)
    #print(help(time))
    #struct_time = time.localtime()
    #print(time.strftime('%Y--%m--%d %H:%M:%S',struct_time))  #2018--02--08 18:05:21 *****
    # print(time.strptime('2018--02--08 18:05:21','%Y--%m--%d %H:%M:%S'))
    # a = time.strptime('2018--02--08 18:05:21','%Y--%m--%d %H:%M:%S')
    # print(a.tm_year)  #2018
    # print(a.tm_hour)  #18
    
    
    #时间戳,结构化时间,格式化时间
    #print(time.ctime())  # Thu Feb  8 21:39:35 2018
    #print(time.ctime(3600))  # Thu Jan  1 09:00:00 1970
    #print(time.mktime(time.localtime()))  # 1518097484.0
    
    import datetime
    
    print(datetime.datetime.now())  #2018-02-09 07:35:47.956193
    #时间
    %Y  Year with century as a decimal number.
    %m  Month as a decimal number [01,12].
    %d  Day of the month as a decimal number [01,31].
    %H  Hour (24-hour clock) as a decimal number [00,23].
    %M  Minute as a decimal number [00,59].
    %S  Second as a decimal number [00,61].
    %z  Time zone offset from UTC.
    %a  Locale's abbreviated weekday name.
    %A  Locale's full weekday name.
    %b  Locale's abbreviated month name.
    %B  Locale's full month name.
    %c  Locale's appropriate date and time representation.
    %I  Hour (12-hour clock) as a decimal number [01,12].
    %p  Locale's equivalent of either AM or PM.
  • 相关阅读:
    大数据处理系列之(二)系统过载保护
    大数据处理系列之(一)Java线程池使用
    js实现递归菜单无限层
    treeTable实现排序
    spring-dm 一个简单的实例
    Equinox OSGi服务器应用程序的配置步骤 (支持JSP页面)
    Spring DM 2.0 环境配置 解决Log4j问题
    Spring.DM web开发环境搭建
    STL容器的排序
    排序例子
  • 原文地址:https://www.cnblogs.com/linpei/p/10980330.html
Copyright © 2011-2022 走看看