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.
  • 相关阅读:
    桌面快捷方式图标问题的修复
    Visual Studio 2015简体中文版
    开源资源记录
    如何在InstallShield的MSI工程中调用Merge Module的Custom Action
    使用Open Live Writer写博客
    使用Window Media Player网页播放器
    Nginx日志常用统计分析命令
    Jetty 开发指南:嵌入式开发示例
    Jetty 开发指南: 嵌入式开发之HelloWorld
    使用Semaphore控制对资源的多个副本的并发访问
  • 原文地址:https://www.cnblogs.com/linpei/p/10980330.html
Copyright © 2011-2022 走看看