Julia 1.7.2 : how to use @sprintf

Viewed 84

I am new to julia 1.7.2. I found on julialang.org about @sprintf. I try to show a number 45 as: 00045

a = @sprintf "%05i" 45           # I get:  @sprintf not defined

a = Printf.@sprintf "%05i" 45    # I get:  Printf not defined

What is missing in this 1 line program? Thanks

1 Answers

You need to import the Printf module first. For example with using (in which case you do not need to prefix @sprintf with Printf):

julia> using Printf

julia> @sprintf "%05i" 45
"00045"
Related