timeago——多久之前 的Python库

发布时间:2019-06-22 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了timeago——多久之前 的Python库脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

timeago

A python lib format datetime to *** time ago. https://github.com/hustcc/timeago

Build Status PyPi Status Python Versions PyPi Downloads

Install

pip install timeago

usage & Example

import timeago, datetime

now = datetime.datetime.now() + datetime.timedelta(seconds = 60 * 3.4)

PRint (timeago.format(date, now)) # will print 3 minutes ago

Methor & Parameter

only one API format.

Three parameters of method format:

  • date: datetime will be done / format.

  • now: reference time, must be instance of datetime.

  • locale: the locale code, only zh_CN / en supported, default en.

Localization

  1. foke the project

  2. add <locale>.py file in the locales folder.

  3. pull a request.

脚本宝典总结

以上是脚本宝典为你收集整理的timeago——多久之前 的Python库全部内容,希望文章能够帮你解决timeago——多久之前 的Python库所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。