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.
  • 相关阅读:
    第02组 Alpha冲刺 (6/6)
    面向对象分析设计考试复习【历年卷】
    第02组 Alpha冲刺 (5/6)
    第02组 Alpha冲刺 (4/6)
    第02组 Alpha冲刺 (3/6)
    第02组 Alpha冲刺 (2/6)
    第02组 Alpha冲刺 (1/6)
    linux内核结构
    从别人的博客学习
    递归的认识
  • 原文地址:https://www.cnblogs.com/linpei/p/10980330.html
Copyright © 2011-2022 走看看