User-friendly time format in Python?

后端 未结 14 1500
[愿得一人]
[愿得一人] 2020-12-12 10:06

Python: I need to show file modification times in the \"1 day ago\", \"two hours ago\", format.

Is there something ready to do that? It should be in English.

14条回答
  •  爱一瞬间的悲伤
    2020-12-12 10:45

    You can also do that with arrow package

    From github page:

    >>> import arrow
    >>> utc = arrow.utcnow()
    >>> utc = utc.shift(hours=-1)
    >>> utc.humanize()
    'an hour ago'
    

提交回复
热议问题