没有逗号的Powershell十进制格式

Wal*_*chi 3 powershell

如何在没有逗号的情况下格式化powershell输出为十进制?我正在使用'{0:N2}'-f $ a但我不想要成千上万的逗号.

EBG*_*een 7

有许多不同的格式字符串.在你的情况下,我会建议:

'{0:d2}' - f $ a

一个很好的参考是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
Run Code Online (Sandbox Code Playgroud)

  • 然后你可能使用'{0:d2}',你的数据有十进制值.我没注意到你原来的帖子.试试'{0:f2}' (2认同)