How to use protected characters in a string (% i.e.)

Hello there.

How do I use these protected characters when writing a string?

@printf "this code has failed in %.2f" fail_percentage

I would like the output to be

this code has failed in 10.00%

but when I use the % symbol, it fails.

Also, I would like to properly print a float, with the proper amount of decimals. Is there a way to do so, without using printf?

thanks in advance.

julia> @printf "this code has failed in %.2f%%" fail_percentage
this code has failed in 10.00%

see: How to escape the % (percent) sign in C's printf - Stack Overflow

4 Likes