如何用千位逗号打印一个整数 [英] How to fmt.Printf an integer with thousands comma

查看:165
本文介绍了如何用千位逗号打印一个整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Go的 fmt.Printf 是否支持以千位逗号输出一个数字?

fmt.Printf(%d,1000)输出 1000 ,我可以指定什么格式输出 / code>而不是?



文档似乎没有提及逗号,我也无法立即看到

没有一个fmt打印动词支持数千个分隔符。

Does Go's fmt.Printf support outputting a number with the thousands comma?

fmt.Printf("%d", 1000) outputs 1000, what format can I specify to output 1,000 instead?

The docs don't seem to mention commas, and I couldn't immediately see anything in the source.

解决方案

None of the fmt print verbs support thousands separators.

这篇关于如何用千位逗号打印一个整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆