Very stupid question about a % symbol
J
dreadpiratejeff at gmail.com
Thu Sep 16 11:25:06 EDT 2010
OK, this is a very stupid question about a very simple topic, but
Google is failing me this morning...
I'm trying to print a string that looks like this:
Reported memory amounts are within 10% tolerance
and the print line looks (for now) like this:
print "Reported memory amounts are within %s%s tolerance" %
(self.mem_tolerance,'%')
Is there a better way to print a '%' in the string when also using formating?
That works, but I've been looking for a way that looks... less kludgey.
I've tried things like this:
print "blahblahblah %s \%" % variable
but the first %s forces every other % to be interpreted as additional
format markers.
So while what I'm doing works, I was hoping someone could either
confirm that that's the right way, or show me a better way.
Cheers
Jeff
More information about the Python-list
mailing list