Learning note(3) for Windows powershell Tips
来源:互联网 发布:软件破解器 编辑:程序博客网 时间:2024/05/22 13:28
- Windows PowerShell每周提示(7):格式化数字
"{0:N0}" -f $a
输出:
19,385,790,464
"{0:N0}" -f $a的解释:
l 初始的0(冒号前的那一个)代表了要被格式化的项目的索引号。目前,保留0的话一切都会正常运行。
l N代表被应用的格式类型;在本例的中,N是Numeric的缩写。还有其它类型的格式能被我们应用么?是,有的,我们待会就向你展示一些。
l 第二个0(N后的那一个)被称为“精度限定符”,如果是数字格式的话,表明小数点后有多少位被显示。在本例中我们不想要任何小数部分,因此我们设置此参数为0。假设我们需要显示3位小数?没有问题,这个命令关心到了这个方面:“{0:N3} –f $a”。运行这个命令,你会看上去像这样的输出结束:19,385,790,464.000
名称
限定符
描述
货币
C
值以货币形式显示,使用精度限定符来限定有几位小数将被显示
数字
D
值以精度限定符中指定的数字数来显示;如有需要,在数字开始处将会被添加前导0。
百分数
P
值被乘以100,然后以百分数形式显示。精度限定符来限定有几位小数将被显示。
16进制
X
值以16进制显示。限定符用来限定字符的显示数量,如有需要将在开始添加前导0。
$a = 348
"{0:N2}" -f $a
"{0:D8}" -f $a
"{0:C2}" -f $a
"{0:P0}" -f $a
"{0:X0}" -f $a
输出:
348.00
00000348
¥348.00
34,800%
15C
- Windows PowerShell每周提示(8):你能用Get-ChildItem Cmdlet所做的酷事
----
DRIVERS
PerfLogs
Program Files
Users
Windows
autoexec.bat
BOOTSECT.BAK
config.sys
WirelessDiagLog.csv
PerfLogs
Program Files
Users
Windows
autoexec.bat
BOOTSECT.BAK
config.sys
WirelessDiagLog.csv
- Windows PowerShell每周提示(9):你能用数组做更多的事
$b = "Green","Orange","Yellow"
$c =$d +$b
- Learning note(3) for Windows powershell Tips
- Learning note(1) for Windows PowerShell Tips
- Learning note(2) for windows powershell Tips
- Learning note(4) for windows powershell Tips
- Learning note(5) for windows powershell Tips
- Learning note(6) for windows powershell Tips
- Learning note(7) for windows powershell Tips
- Learning note(8) for windows powershell Tips
- PowerShell learning note
- Windows Azure Learning Note (3)
- Stady notes: Windows powershell tips
- Windows powershell tips:Conditional Operators
- Tips for learning ActionScript 3.0
- Windows Azure Learning Note (1)
- Windows Azure Learning Note (2)
- Windows Azure Learning Note (5)
- 【Deep Learning】笔记:Tips for deep learning
- 10 Tips for Learning a New Technology
- Linux 进程管理剖析
- 时政类题库竞赛资源
- C#编写一个支持Mysql,Acces,SQL数据库类(支持存储过程)
- “祖国在我心中”纪念建国60周年知识竞赛(共青团知识)
- 正则表达式(积累中),希望对大家分析数据有帮助
- Learning note(3) for Windows powershell Tips
- 诗
- 用 Bleachbit 来给 Ubuntu 9.04 “减肥”
- DataReader用完后一定要关闭!
- 程序员的十层楼:大家都来测测你的技术层级
- c++中不同类之间的赋值(重载运算符= 即operator =)
- VC6.0 控件Radio Button的使用
- 在struts2中加入装饰器sitemesh
- 从公司的控件布局的实现类中学到的一点东西