zoukankan      html  css  js  c++  java
  • datetime相减

    >>> datetime.datetime.now()
    datetime.datetime(2012, 3, 19, 8, 40, 39, 966543)
    >>> datetime.datetime.now()
    datetime.datetime(2012, 3, 19, 8, 40, 44, 441431)
    >>> a=datetime.datetime.now()
    >>> a
    datetime.datetime(2012, 3, 19, 8, 40, 50, 737418)
    >>> b=datetime.datetime.now()
    >>> b
    datetime.datetime(2012, 3, 19, 8, 41, 3, 849623)
    >>> b-a
    datetime.timedelta(0, 13, 112205)
    >>> (b-a).seconds
    13
    >>> (b-a).days
    0
    >>> (b-a).hours
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    AttributeError: 'datetime.timedelta' object has no attribute 'hours'
    >>> (b-a).hour
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    AttributeError: 'datetime.timedelta' object has no attribute 'hour'
    >>> (b-a).minutes
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    AttributeError: 'datetime.timedelta' object has no attribute 'minutes'
    >>> (b-a).microseconds 微妙
    112205
    >>> 849623-737418
    112205
    >>>

  • 相关阅读:
    Redis
    Redis
    Redis
    linux 安装docker
    linux 安装nexus
    linux 安装jenkins
    linux 安装gitlab
    python 类的继承
    python raise & assert
    python super()
  • 原文地址:https://www.cnblogs.com/SophiaTang/p/2405470.html
Copyright © 2011-2022 走看看