zoukankan      html  css  js  c++  java
  • 模块-time

    #当前时间戳
    time.time()
    #将时间戳转换为本地时间对象,不传值返回当前系统时间的本地时间对象
    lt=time.localtime(time.time())
    #类似localtime,将时间戳转换为UTC时区(比北京时间早8小时)的时间对象,不提工参数以本地时间为准
    gt=time.gmtime()
    #将时间对象转换为时间戳
    lt=time.localtime(time.time())
    time.mktime(lt)
    #将时间元组或者时间戳对象转换成国外显示方式
    #无参数转换本地时间
    time.asctime(11111111111111)
    #将时对象转换成指定格式字符串,不指定时间对象,则转本地时间
    time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(time.time()))
    # %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.

    快速计算当前是今年第多少周

    time.strftime('%U',time.localtime(time.time()))

    将字符串转换成时间对象

    s=time.strftime("%Y-%m-%d %H:%M:%S")
    >>> s
    '2018-04-09 20:40:45'
    >>> s2=time.strptime(s,"%Y-%m-%d %H:%M:%S")
    >>> s2
    time.struct_time(tm_year=2018, tm_mon=4, tm_mday=9, tm_hour=20, tm_min=40, tm_sec=45, tm_wday=0, tm_yday=99, tm_isdst=-1)
    >>> time.mktime(s2)
    1523277645.0

  • 相关阅读:
    框架
    css样式表。作用是美化HTML网页.
    表单的制作
    表格的制作
    常用标签的制作
    标签的制作
    poj2104(K-th Number)
    Codeforces Round #359 (Div. 2) D. Kay and Snowflake
    Codeforces Round #359 (Div. 2) C. Robbers' watch
    HDU3308(LCIS) 线段树好题
  • 原文地址:https://www.cnblogs.com/yaya625202/p/8761367.html
Copyright © 2011-2022 走看看