Search code examples
stringjuliastring-formatting

How to format an integer with zero padding in Julia?


If I have an Integer, say 123, how can I get a zero-padded string of it to a certain length?

For example, 123 with 6 wide would become "000123", but 1234567 to 6 wide would be "1234567".


Solution

  • julia> string(123, pad=6)
    "000123"