gpt4 book ai didi

不带逗号的 Powershell 十进制格式

转载 作者:行者123 更新时间:2023-12-03 14:06:10 26 4
gpt4 key购买 nike

如何将 powershell 输出格式化为不带逗号的十进制?我正在使用 '{0:N2}' -f $a 但我不想用逗号表示千位。

最佳答案

有很多不同的格式字符串。对于您的情况,我建议:

'{0:d2}' -f $a

一个很好的引用是 String Formatting in C#

实际上这里有一些例子:

$a = 124000.4201

'{0:g2}' -f $a
1.2e+05

'{0:f2}' -f $a
124000.42

# and since it is using the .net formatter for all this after all
'{0:00.0000}' -f $a
124000.4201

关于不带逗号的 Powershell 十进制格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9218060/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com