Setting fixed length with python

前端 未结 5 1220
遇见更好的自我
遇见更好的自我 2021-01-05 02:19

I have str that are like \'60\' or \'100\'. I need the str to be \'00060\' and \'00100\',

How can i do this? code is something like this: I was using \'0\'+\'0\'+

5条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-05 02:26

    Reading your favorite Python documentation appreciated:

    http://docs.python.org/library/string.html#formatstrings

    """

    If the width field is preceded by a zero ('0') character, this enables zero-padding. This is equivalent to an alignment type of '=' and a fill character of '0'. """

提交回复
热议问题