在批处理中添加逗号作为数字字符串

发布于 2025-02-13 05:48:34 字数 172 浏览 0 评论 0原文

我想知道是否有一个简单的代码可以添加逗号作为数千个分离器,以考虑数字的长度。例如,如果变量等于123576我希望它成为123,456,但是如果变量等于1234567,那么我希望它想要它要变成1,234,567

I was wondering if there was a simplistic code to add commas as thousands separators in variables that takes into account the length of the digit. For example, if The variable equals 123576 I would want it to become 123,456, but if the variable were equal to 1234567 then I would want it to turn into 1,234,567.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

酒废 2025-02-20 05:48:34
ECHO Processing %num%
SET "withcommas="
:subl
IF DEFINED num SET "withcommas=%num:~-3%,%withcommas%"&SET "num=%num:~0,-3%"&GOTO subl
SET "withcommas=%withcommas:~0,-1%"
ECHO result=%withcommas%

流程num需要格式。注意:num将被代码不确定。

ECHO Processing %num%
SET "withcommas="
:subl
IF DEFINED num SET "withcommas=%num:~-3%,%withcommas%"&SET "num=%num:~0,-3%"&GOTO subl
SET "withcommas=%withcommas:~0,-1%"
ECHO result=%withcommas%

Processes num to required format. Note : num will be undefined by code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文