0
querystring = cgi.parse_qs(decrypted_qs)

self.response.out.write(querystring) #output: {'param2': ['v2'], 'param1': ['v1']}

self.response.out.write(querystring.param2) #AttributeError: 'dict' object has no attribute 'param2'

The original dict: {'param1': 'v1', 'param2': 'v2'}

So why isn't the second one working, what's the right way to access the values?

I'm running Python 2.5.2 on App Engine.

2 Answers 2

1

Python dicts don't work like JavaScript dicts. You need to use it the same way you access elements in a list:

querystring['param2']
Sign up to request clarification or add additional context in comments.

1 Comment

Oh well that was fast. How'd I miss that? :P
0

Don't attempt to extract query string parameters yourself in the first place - use your framework. If you're using webapp, you can access query string parameters through the dict self.request.GET.

1 Comment

@Wooble I'll leave mine, since it's impossible to tell that from the question, and others may arrive here with the same query.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.