Guest User

Untitled

a guest
Oct 21st, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. def parse_query(query):
  2. query_dictionary = {}
  3. split_query = query[1:].split('&')
  4. for item in split_query:
  5. item_key, item_val = item.split('=')[0], item.split('=')[1]
  6. if item_key not in query_dictionary:
  7. query_dictionary[item_key] = item_val
  8. elif item_key in query_dictionary:
  9. prev_contents = query_dictionary[item_key]
  10. query_dictionary[item_key] = [prev_contents]
  11. query_dictionary[item_key].append(item_val)
  12. return query_dictionary
Add Comment
Please, Sign In to add comment