close

[Solved] ValueError: unsupported format character while forming strings

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error ValueError: unsupported format character while forming strings in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How ValueError: unsupported format character while forming strings Error Occurs?

Today I get the following error ValueError: unsupported format character while forming strings in python.

How To Solve ValueError: unsupported format character while forming strings Error ?

  1. How To Solve ValueError: unsupported format character while forming strings Error ?

    To Solve ValueError: unsupported format character while forming strings Error Well, why do you have %20 url-quoting escapes in a formatting string in first place? Ideally you'd do the interpolation formatting first:

  2. ValueError: unsupported format character while forming strings

    To Solve ValueError: unsupported format character while forming strings Error Well, why do you have %20 url-quoting escapes in a formatting string in first place? Ideally you'd do the interpolation formatting first:

Solution 1

You could escape the % in %20 like so:

print "Hello%%20World%s" %"!"

or you could try using the string formatting routines instead, like:

print "Hello%20World{0}".format("!")

Solution 2

Well, why do you have %20 url-quoting escapes in a formatting string in first place? Ideally you’d do the interpolation formatting first:

formatting_template = 'Hello World%s'
text = '!'
full_string = formatting_template % text

Then you url quote it afterwards:

result = urllib.quote(full_string)

That is better because it would quote all url-quotable things in your string, including stuff that is in the text part.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read