• 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
    >>>

  • 相关阅读:
    第五章
    第四章
    第三章
    第二章
    第一章
    configparser-xml-subprocess-shutil
    sys,os,模块-正则表达式
    %----format 格式化字符串---- 生成器---- 迭代器
    python 内置函数
    python 内置函数!
  • 原文地址:https://www.cnblogs.com/SophiaTang/p/2405470.html
Copyright © 2020-2023  润新知