469,313 Members | 2,261 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,313 developers. It's quick & easy.

urllib.urlencode multidimensional dictionary

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
0 2136

Post your reply

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

Similar topics

1 post views Thread by Steve Allgood | last post: by
2 posts views Thread by Sean Berry | last post: by
11 posts views Thread by Pater Maximus | last post: by
reply views Thread by Pieter Edelman | last post: by
1 post views Thread by Timothy Wu | last post: by
12 posts views Thread by sleytr | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.