且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 Erlang 中使用填充格式化数字

更新时间:2023-11-10 10:11:28

对 Zed 的回答加一点解释:

adding a bit of explanation to Zed's answer:

Erlang 格式规范是:~FPPadModC.

Erlang Format specification is: ~F.P.PadModC.

"~4..0B~n" 翻译成:

 ~F. = ~4.  (Field width of 4)
  P. =   .  (no Precision specified)
Pad  =  0   (Pad with zeroes)
Mod  =      (no control sequence Modifier specified)
  C  =  B   (Control sequence B = integer in default base 10)

~n 是换行符.