zoukankan      html  css  js  c++  java
  • python datetime模块

    一、datetime与time模块的区别

    用datetime模块计算几天前后比较方便些,time模块还需要通过转时间戳来转换

    二、常见用法

     print(datetime.date.today())#当天日期,打印2018-07-11
    print(datetime.datetime.today())#当天的时间,有日期有时间 打印2018-07-11
    print(datetime.date.today()+datetime.timedelta(-1))#1天前
    print(datetime.date.today()+datetime.timedelta(10))#10天后
    print(datetime.date.today()+datetime.timedelta(hours=-10,minutes=-20,seconds=-30))#10小时零20分钟30秒以前
    res = datetime.datetime.today()+datetime.timedelta(hours=-10,minutes=-20)
    print(res.time())#只取到时间
    print(res.date())#只取到日期
    print(res.timestamp())#时间戳
    print(res.strftime('%Y-%m %H:%M%S'))#按照格式获取时间 2018-07 05:5207

  • 相关阅读:
    填充与复制
    张量排序
    数据统计
    合并与分割
    前向传播(张量)- 实战
    数学运算
    Broadcasting
    TensorFlow2-维度变换
    集合3
    集合2
  • 原文地址:https://www.cnblogs.com/morning1/p/9295170.html
Copyright © 2011-2022 走看看