Convert spaces to %20 in list
I would recommend using urllib.parse
module and its quote()
function.
https://docs.python.org/3.6/library/urllib.parse.html#urllib.parse.quote
Example for Python3:
from urllib.parse import quote
text_encoded = quote(t.text)
Note: using quote_plus()
won't work in your case as this function replaces spaces by plus char.
Use the String.replace()
method as described here: http://www.tutorialspoint.com/python/string_replace.htm
So for t.text
, it would be t.text.replace(" ", "%20")