This works:
print "Hello World%s" %"!"
But this doesn’t
print "Hello%20World%s" %"!"
the error is ValueError: unsupported format character 'W' (0x57) at index 8
I am using Python 2.7.
Why would I do this? Well %20 is used in place of spaces in urls, and if use it, I can’t form strings with the printf formats. But why does Python do this?
You could escape the % in %20 like so:
or you could try using the string formatting routines instead, like:
http://docs.python.org/library/string.html#formatstrings