By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,270 Members | 1,703 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,270 IT Pros & Developers. It's quick & easy.

urllib.urlencode multidimensional dictionary

P: 15
Hi all,

I am trying to use urllib.urlencode to post a multidimensional dictionary to a php page.

This is the code I am using

Expand|Select|Wrap|Line Numbers
  1. test = {}
  2. test['boom'] = {}
  3. test['boom']['zoom'] = "bang"
  4.  
  5. server_params = urllib.urlencode(test)
  6.  
  7. response = urllib2.urlopen(server_url, server_params).read()
  8.  
And if I do a print of the post variable from php my output is looking like this

Expand|Select|Wrap|Line Numbers
  1. Array
  2. (
  3.     [boom] => {\'zoom\': \'bang\'}
  4. )
  5.  
Only the first key of the dictionary is being preserved while everything underneath is being squished into a string.

Is there a way to preserve the entire structure of the dictionary?

Thanks!
Mar 6 '09 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.