I would like the output to be this
I'm using '%s' to print this out: hello!
My code:
print "I'm using %s to print this out: %s" % "hello!"
This returns an error.
I would like the output to be this
I'm using '%s' to print this out: hello!
My code:
print "I'm using %s to print this out: %s" % "hello!"
This returns an error.
Put a second %
before the literal one:
print "I'm using %%s to print this out: %s" % "hello!"
This isn't a Python-specific solution: C's printf
, and other analogues (such as the shell printf
) work the same way.