Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def parse_query(query):
- query_dictionary = {}
- split_query = query[1:].split('&')
- for item in split_query:
- item_key, item_val = item.split('=')[0], item.split('=')[1]
- if item_key not in query_dictionary:
- query_dictionary[item_key] = item_val
- elif item_key in query_dictionary:
- prev_contents = query_dictionary[item_key]
- query_dictionary[item_key] = [prev_contents]
- query_dictionary[item_key].append(item_val)
- return query_dictionary
Add Comment
Please, Sign In to add comment