julia> fspec = FormatSpec(",d")
Formatting.FormatSpec
cls = i
typ = d
fill =
align = >
sign = -
width = -1
prec = -1
ipre = false
zpad = false
tsep = true
julia> printfmt(fspec, 10^9)
1000000000
fexpr = FormatExpr("{:,d}")
printfmt(fexpr, 10^9)
1000000000
@printf("x = %s\n", sprintf1("%'i", x))
val = 123456789
fmt_default!(Integer, :commas)
println(u"This is a lot of money: $\%(val)")
println(u"Let's output with commas: \%(val, :commas)")
x = 10^9
using Formatting
s = fmt(",d", x) # python-style format spec (single value)
s = format("{:,d}", x) # python-style form expression (multiple values)
s = sprintf1("%'d", x) # c-style
s = format(x, commas=true) # keyword arguments
using StringUtils
s = u"\%(x, :commas)"
println("x = $s")
println("x = ", s)
@printf("x = %s\n", s)
Thanks Tom & Scott.StringUtils looks quite useful. I'll need to study it a bit more.
julia> u"\%-10.4f(1.234234)"
"1.2342 "
julia> u"\%20'.2f(1234234.234234)"
" 1,234,234.23"