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

    """
    时间模块
    import time
    三种表现形式
        1.时间戳
        2.格式化时间(用来展示给人看的)
        3. 结构化时间
    
    """
    # import time
    # print(time.time())#显示的是从1970:1月1日凌晨00:00到现在的时间
    # #结果:1563446269.2257721
    # print(time.strftime("%Y-%m-%d"))
    # #结果:2019-07-18 #显示的是当前时间
    # print(time.strftime("%Y-%m-%d %H:%M:%S" ))
    # #结果显示的是2019-07-18 18:43:09 显示的是年月日 小时分钟秒
    # print(time.strftime("%X"))
    # #结果 %X就等价于%H:%M:%S  18:45:23
    
    import datetime
    print(datetime.date.today())
    #结果显示 data>>显示的是年月日
    print(datetime.datetime.today())
    #结果显示 datetime >>显示的是年月日 时分秒
    res = datetime.date.today()
    print(res)  # 用res接受打印结果和上面一样
    print(res.year)  #打印 年
    print(res.month)  # 打印月
    print(res.day)    # 打印日
    print(res.weekday())  #打印星期几 国外0-6  0 表示周一
    print(res.isoweekday()) #打印星期几  1-7 7 表示的就是周日
    
    """
    日期对象 = 日期对象+/- timedelta 对象
    timedelta对象 = 日期对象 +/- 日期对象
    
    
    """
    current_time = datetime.date.today()  # 日期对象
    # timetel_t = datetime.timedelta(days=7)  # timedelta对象
    # res1 = current_time+timetel_t  # 日期对象
    #
    # print(current_time - timetel_t)
    # print(res1-current_time)
    
    
    # 小练习 计算今天距离今年过生日还有多少天
    # birth = datetime.datetime(2019,12,21,8,8,8)
    # current_time = datetime.datetime.today()
    # print(birth-current_time)
    
    # UTC时间
    # dt_today = datetime.datetime.today()
    # dt_now = datetime.datetime.now()
    # dt_utcnow = datetime.datetime.utcnow()
    # print(dt_utcnow,dt_now,dt_today)
  • 相关阅读:
    业务逻辑安全之登陆认证模块
    linux下的tcpdump
    wirshark使用(二)
    wirshark 使用(一)
    MVC框架的代码审计小教程
    记一次发卡网代码审计
    HTML知识点(一)
    jQuery基础、效果和事件
    Ajax知识(二)
    jQueryHTML和插件、display和overflow和visibility的区别
  • 原文地址:https://www.cnblogs.com/yangxinpython/p/11209381.html
Copyright © 2011-2022 走看看