Question
Asked By – Juanjo Conti
I see I can’t do:
"%b %b" % (True, False)
in Python. I guessed %b
for b(oolean). Is there something like this?
Now we will see solution for issue: How are booleans formatted in Strings in Python?
Answer
>>> print "%r, %r" % (True, False)
True, False
This is not specific to boolean values – %r
calls the __repr__
method on the argument. %s
(for str
) should also work.
This question is answered By – danben
This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0