timeago——多久之前 的Python库
文章目录
timeago
A python lib format datetime to *** time ago. https://github.com/hustcc/timeago
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:datetimewill be done / format.now: reference time, must be instance ofdatetime.locale: the locale code, only zh_CN / en supported, defaulten.
Localization
foke the project
add <locale>.py file in the locales folder.
pull a request.





评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论