开发者

Rails, When displaying a number, if 0 or under 10, always show two 00 zeos

I have query which returns a count. Regardless of whether is 0 or 4 (anything under 10, I always want the number to display like so:开发者_开发百科

If / Display:
0 / 00
2 / 02
12 / 12

IE always with the 00 place holder. Is there a helper method for this or is this a custom job?


Try this:

"%02d" % my_int

For documentation, see here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜