如何 fmt.Printf 一个带有千位逗号的整数 [英] How to fmt.Printf an integer with thousands comma

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

问题描述

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

fmt.Printf("%d", 1000) 输出1000,我可以指定什么格式输出1,000?>

文档 似乎没有提到逗号,我无法立即看到任何内容来源.

解决方案

没有一个 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.

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

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