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.
精彩评论