首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏JackeyGao的博客

    Django小技巧02: humanize

    使用方法也非常简单: 在 settings.py INSTALLED_APPS 加入django.contrib.humanize. django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.humanize Django/Jinja {% load humanize %} 使用过滤器也非常简单, 比如使用naturaltime过滤器. Django/Jinja {% extends 'base.html' %} {% load humanize %} {% block content %}

      {% for notification => yesterday naturaltime 友好的时间 2018-10-25 12:00:01 => a minute ago. ordinal 序数字符串 3 => 3rd 阅读更多关于humanize

    1.6K10发布于 2018-12-04
  • 来自专栏BETTER

    django.contrib.humanize NUMBER_GROUPING

    要件:数字format,例:1234567→1,234,567方案:使用 django.contrib.humanize步骤:1,INSTALLED_APP添加humanizeINSTALLED_APPS = [ 'django.contrib.humanize',]NUMBER_GROUPING = 3 # 若使用language为ja 日语,需要追加,后续说明2,templete 追加{% load humanize %}3,使用,filter【|】{{ value|intcomma }}用例:pj>templetes>xxxlist.html{% extends 'base.html ' %}{% load humanize %}{% block content %}

    {{ value|naturaltime }}

    <!

    41520编辑于 2022-08-17
  • 来自专栏人人都是架构师

    humanize:将数字转换成更加易读易理解的格式

    什么是humanizehumanize是一个Python库,它提供了一系列的函数,用于将数字转换成更加易读易理解的格式。 humanize如何工作? humanize库内部实现了一系列的格式化函数,这些函数根据输入的数字类型(如整数、浮点数、日期等),选择相应的算法进行转换。 在开始之前,确保你的环境中已经安装了humanizehumanize就能帮我们做到这一点。 import humanize print(humanize.intword(1234567890)) # 输出: 1.2 billion 时间的人性化 处理时间和日期也是humanize的强项。

    62110编辑于 2025-01-18
  • 来自专栏人人都是架构师

    Go每日一库之130:go-humanize(人性化显示)

    bytes ,我们可不太好理解,但是如果说容量是 83M ,那就好理解了,go-humanize干的就是这个事情。 /dustin/go-humanize" 就可以使用了。 ", humanize.Bytes(82854982000)) // That file is 83 GB. 加3个0,就是GB了。 这个函数和 humanize.Bytes 是一样的,它也会根据相对的时间,转换为 xxx分钟前 xxx小时前 或者 xxx 天前 等等。 \n", humanize.Comma(6582491)) // You owe ¥6,582,491.

    66730编辑于 2023-09-30
  • 来自专栏DotNet NB && CloudNative

    Humanizer:简化DotNet日期、时间和数字的本地化表达

    ".Humanize()); //输出:Underscored input string is turned into sentence 字符串 Humanize字符串扩展允许您将原本计算机化的字符串转换为更具可读性 ".Humanize(LetterCasing.AllCaps); //"CAN HUMANIZE INTO UPPER CASE" "Sentence casing".Transform(To.LowerCase (1).Humanize() => "an hour from now" TimeSpan 处理 TimeSpan.FromMilliseconds(1).Humanize() => "1 millisecond " TimeSpan.FromMilliseconds(2).Humanize() => "2 milliseconds" TimeSpan.FromDays(1).Humanize() => "1 day 日期和时间 • Humanize DateTime:将日期时间转换为相对时间描述。 • 昨天、2小时后。 • Humanize TimeSpan:将时间跨度转换为自然语言。 • 2周、1天。

    75610编辑于 2025-04-09
  • 来自专栏Crossin的编程教室

    那些小众但实用的Python库

    可视化缺失值矩阵 msno.matrix(df) 仓库地址:https://github.com/ResidentMario/missingno 安装命令:pip install missingno Humanize Humanize 是一个轻量级库,用于将数字、日期和文件大小等数据转换为人类易读的格式。 代码示例: import humanize # 格式化文件大小 print(humanize.naturalsize(1234567)) # 输出: 1.2 MB # 格式化时间差 print(humanize.naturaltime (3600)) # 输出: an hour ago # 小数转分数 print(humanize.fractional(0.3847192)) # 科学计数法 print(humanize.scientific (500123481234712)) 仓库地址:https://github.com/python-humanize/humanize 安装命令:pip install humanize 感谢转发和点赞的各位

    13610编辑于 2026-03-11
  • 来自专栏Go工具箱

    「Go工具箱」将文件大小转换成Kb、Mb、Gb就用这个库:go-humanize

    它能将数字、时间转换成更人性化可读的函数库:go-humanize。 以下是go-humanize的基本情况: go-humanize小档案 star 3.3k used by 20.2k contributors 23 工具分类 效率 功能简介 将时间、数字更人性化展示的函数库 ", humanize.Bytes(82854982)) // That file is 83 MB. ", humanize.Time(someTimeInstance)) 将数字转换成序数 例如将1转换成第1st个,2转换成第2nd个: 0 -> 0th 1 -> 1st 2 -> 2nd 3 -> \n", humanize.Comma(6582491)) 更多项目详情请查看如下链接。

    2.1K10编辑于 2023-01-31
  • 来自专栏sktj

    Django2.0中文(人性化数据)

    包 django.contrib.humanize 包含了一些是数据更人性化的模板过滤器。 要激活这些过滤器,请把 ‘django.contrib.humanize’ 加入到你的 INSTALLED_APPS 中。 完成之后,向模版了加入 {% load humanize %} 就可以使用下面的过滤器了。 名称 用法 apnumber 对于1到9的数字,该过滤器返回了数字的拼写形式。 将整数转换为每三个数字用一个逗号分隔的字符串 intword 将一个很大的整数转换成友好的文本表示方式,1200000 变成1.2million ordinal 将整数转换为序数词的字符串形式 {% load humanize

    38410编辑于 2022-05-14
  • 来自专栏快乐阿超

    js日期、经纬度格式化

    31557600000, '月': 2629800000, '天': 86400000, '小时': 3600000, '分钟': 60000, '秒': 1000 }, // 人性化 humanize : function(milliseconds) { var humanize = ''; for (var key in this.UNITS) { if (milliseconds > = this.UNITS[key]) { humanize = Math.floor(milliseconds / this.UNITS[key]) + key + '前'; break ; } } return humanize || '刚刚'; }, // 一天内人性化 一天后格式化 formatHumanize: function(dateStr) { var + locationData.longitude) console.log("纬度:" + locationData.latitude) console.log("人性化:" + dateUtils.humanize

    7.2K20编辑于 2022-08-16
  • 来自专栏GoLang全栈

    文件大小、千分位转换用这个库就牛逼了

    库的安装介绍 库的 github 地址:github.com/dustin/go-humanize start 的数量还算可以。 安装的话,直接 go get 即可: go get github.com/dustin/go-humanize 使用 文件大小转换 直接上代码吧: info,_ := os.Stat(". /main.go") // 打印 byte fmt.Println(info.Size()) // 使用 humanize 转换 fmt.Println(humanize.Bytes(uint64(info.Size ()))) 这里库的 humanize.Bytes 方法,会返回一个计算后的带单位的字符串,比如 B M G T 这种: 508 508 B 时间转换 我们经常可以看到某篇文章,或者某条评论发布于多久之前 直接上代码: fmt.Println(humanize.Commaf(float64(10000000))) 它会给我们转化成这样: 10,000,000 这要是我卡上的数字该多好,哈哈。

    1.2K50编辑于 2022-05-10
  • 来自专栏大飞的部落阁

    Arrow时间处理神器

    print(now.shift(years=-8).date()) 更加人性化的时间和日期 在实际开发中,我们通常会对操作时间等进行人性化的提示,此时我们可以使用 arrow 的 shift 的 humanize now = arrow.now() # 提前5个小时 print(now.shift(hours=-5).humanize()) # 推迟2天 print(now.shift(days=+2).humanize ()) # 提前8年 print(now.shift(years=-8).humanize()) 以上就是今天的全部内容了,感谢您的阅读,我们下节再会。

    53910编辑于 2022-06-17
  • 来自专栏科控自动化

    [C#] Humanizer 让.NET中的类型可读性更友好

    要将日期和时间转换为相对时间格式,请使用Humanizer库中的扩展方法“Humanize”: DateTime dateTime = DateTime.Now.AddDays(-3); string relativeTime = dateTime.Humanize(); // "3 days ago" 除了将日期和时间转换为相对时间格式之外,Humanizer库还支持将日期和时间转换为其他格式, (); // "today at 9:49 PM" string shortFormat = dateTime.ToString("d", new CultureInfo("en-US")).Humanize // "today" string customFormat = dateTime.ToString("yyyy-MM-dd hh:mm:ss", new CultureInfo("en-US")).Humanize (); // "12.35%" string scientificFormat = number.ToString("E2", new CultureInfo("en-US")).Humanize();

    1.5K31编辑于 2023-10-07
  • 来自专栏hotqin888的专栏

    中文全文检索技术路线(elasticsearch全文检索、中文分词ik、tika解析文档)

    (int64(numItems)), numWorkers, humanize.Bytes(uint64(flushBytes))) log.Println(strings.Repeat("▁", 65 (int64(biStats.NumFlushed)), humanize.Comma(int64(biStats.NumFailed)), dur.Truncate(time.Millisecond ), humanize.Comma(int64(1000.0/float64(dur/time.Millisecond)*float64(biStats.NumFlushed))), ) } else { log.Printf( "Sucessfuly indexed [%s] documents in %s (%s docs/sec)", humanize.Comma(int64 (biStats.NumFlushed)), dur.Truncate(time.Millisecond), humanize.Comma(int64(1000.0/float64(dur/

    1.4K20编辑于 2021-12-06
  • qclaw龙虾工作流:用 "rlcr" 思想实现 AI 自我监督

    ##二、RLCR思想:从humanize项目学到的前阵子研究了用claude/codex写代码发现一个humanize项目,里面有个核心概念叫**RLCR**(Ralph-LoopwithCodexReview humanize仓库:PolyArch/humanize:FromAutomatedIdeaFactorytoRealization---*本文基于humanize项目的RLCR思想,结合QClaw实际场景设计 感谢humanize团队的开源贡献。*

    10500编辑于 2026-04-20
  • qclaw龙虾工作流:用 "rlcr" 思想实现 AI 自我监督

    二、RLCR思想:从humanize项目学到的前阵子研究了用claude/codex写代码发现一个humanize项目,里面有个核心概念叫RLCR(Ralph-LoopwithCodexReview), humanize仓库:PolyArch/humanize:FromAutomatedIdeaFactorytoRealization本文基于humanize项目的RLCR思想,结合QClaw实际场景设计 感谢humanize团队的开源贡献。

    15010编辑于 2026-04-21
  • 来自专栏蛰虫始航

    Python处理时间数据的另一种选择,在标准库之外|Arrow使用笔记

    Arrow的另一大特色是可以把时间对象转为人类容易理解的自然语言形式进行输出,对应的方法为dt.humanize(),humanize还可以根据locale参数输出特定语言的自然语言,有趣的封装。 dt=arrow.now().shift(hours=-1) dt.humanize() #当前时间的自然语言表示 #'an hour ago' future =dt.shift(minutes=75) dt.humanize(future, granularity="minute") #'in 75 minutes' #两个时间的对比自然语言表示 dt.humanize(locale='ko_kr'

    1.6K20发布于 2020-12-30
  • 来自专栏前端侠2.0

    JQUERY不请求文件,只请求文件大小的方法 原

    : function(xhr){ // Append the filesize to each $(link).append(' (' + humanize (xhr.getResponseHeader('Content-Length')) + ')'); } }); }); function humanize(size

    90030发布于 2018-09-21
  • 来自专栏有文化的技术人

    Etcd数据恢复机制

    zap.Uint("max-request-bytes", cfg.MaxRequestBytes), zap.String("max-request-size", humanize.Bytes zap.Uint64("snapshot-index", snapshot.Metadata.Index), zap.String("snapshot-size", humanize.Bytes backend from snapshot", zap.Int64("backend-size-bytes", s1), zap.String("backend-size", humanize.Bytes )), zap.Int64("backend-size-in-use-bytes", s2), zap.String("backend-size-in-use", humanize.Bytes

    69950编辑于 2023-08-19
  • 来自专栏信数据得永生

    django 1.8 官方文档翻译: 4-2-4 人性化

    网站:http://python.usyiyi.cn/django/index.html django.contrib.humanize 一系列Django的模板过滤器,有助于向数据添加“人文关怀” 把’django.contrib.humanize’添加到INSTALLED_APPS设置来激活这些过滤器。 执行以上步骤之后,在模板中使用{% load humanize %} ,你就可以访问到下面的过滤器了·。 基数词 对于数字1~9,返回拼写出来的数字。否则返回数字本身。这样遵循了出版的格式。

    37030编辑于 2022-11-27
  • 来自专栏用户2910674的专栏

    7 个令人惊叹的 Python 库

    output = remove(input) # Saving file cv2.imwrite(output_path, output) 输入本地目录存入待处理的照片: 输出扣去背景的效果: 6 Humanize 安装 pip install humanize 示例-整数 # Importing library import humanize import datetime as dt # Formatting numbers with comma a = humanize.intcomma(951009) # converting numbers into words b = humanize.intword (10046328394) #printing print(a) print(b) 输出 951,009 10.0 billion 示例日期和时间 import humanize import datetime as dt a = humanize.naturaldate(dt.date(2012, 6, 5)) b = humanize.naturalday(dt.date(2012, 6, 5)

    1.8K31编辑于 2023-10-24
领券