Wednesday, January 13, 2016

Python printing percent signs

Since percent is used as a formatting character, obviously it needs to be escaped somehow in formatted print statements to appear as itself. It turns out that the way to do this is to use two percent signs to print one, rather than using the backslash for escaping. The following slightly snarky forum answer describes this:

https://bytes.com/topic/python/answers/540689-printing-percent-sign