Search code examples
pythonstring-parsing

URL like string parsing in python


I need to parse a string which is more or less a url.. for example i have a string which is a URL

tempString = "?var1=somevalue1&var2=somevalue2&var3=somevalue3"

i need to parse the string tempString and get the value of var1 var2 and var3 from it. What's the best way to get the value.


Solution

  • Use urlparse.parse_qs.