格式化數字字串

來源:互聯網
上載者:User

標籤:strong   text   字串   mat   格式化   影響   

標準數字格式字串:

C or c  貨幣     "{0:C}" -f 1.23   結果:¥1.23 或 $1.23

D or d 十進位  "{0:D}" -f 2        結果:0002

E or e 科學計數法 "{0:E3}" -f [Math]::Pi 結果:3.142E+000

F or f 固定的點。精確說明小數點後的位元 "{0:F3}" -f [Math]::Pi 結果:3.142

N or n 數字 "{0:N4}" -f 1mb 結果:1,048,576.0000

P or p 百分比 "{0:P4}" -f 0.67 結果:67.0000%

 

自訂數字格式字串:

0 零預留位置    "{0:00.0}" -f 4.12341234 結果:04.1

# 數字預留位置  "{0:##.#}" -f 4.12341234 結果:4.1  

, 千位分隔字元   "{0:#,#.#}" -f 1234.12341234 結果:1,234.1 

,, 縮放比例  如果放置在格式文本(或隱式)小數點之前時,將會除以1000    “{0:##,,.000}” -f 1048576 結果:1.049

% 百分比,將輸入乘以100,並插入百分比符號  “{0:%##.000}” -f .68 結果:68.000%

‘text‘ 文本字串,插入按原義提供的文本到輸出,而不會影響格式 "{0:#.00‘##‘}" -f 2.71828 結果:2.72##

Other 其他字元,插入按原義提供的文本到輸出,而不會影響格式 "{0:$## Please}" -f 14 結果:$14 Please

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.