472,779 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,779 software developers and data experts.

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"
  5. server_params = urllib.urlencode(test)
  7. response = urllib2.urlopen(server_url, server_params).read()
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. )
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?

Mar 6 '09 #1
0 2226

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

Similar topics

by: Steve Allgood | last post by:
I'm having trouble posting a form at the USPS web site. I've been successful using urllib at other sites, but I'm missing why this won't work: # begin code # get zip+4 import urllib def...
by: Sean Berry | last post by:
I have two lists... one like the following, list1 ... and the other like this, list2 ... , ] Both lists are much more extensive, the first being a list of about 10 strings, and the...
by: Pater Maximus | last post by:
I am trying to implement the recipe listed at http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/211886 However, I can not get to first base. When I try to run import urllib...
by: Pieter Edelman | last post by:
Hi all, I'm trying to submit some data using a POST request to a HTTP server with BASIC authentication with python, but I can't get it to work. Since it's driving me completely nuts, so here's...
by: Timothy Wu | last post by:
Hi, I'm trying to fill the form on page http://www.cbs.dtu.dk/services/TMHMM/ using urllib. There are two peculiarities. First of all, I am filling in incorrect key/value pairs in the...
by: sleytr | last post by:
Hi, I'm trying to make a gui for a web service. Site using character in value of some fields. But I can't encode this character properly. >>> data = {'key':''} >>> urllib.urlencode(data)...
by: evanpmeth | last post by:
I have tried multiple ways of posting information to a website and have failed. I have seen this problem on other forums can someone explain or point me to information on how POST works through...
by: gmguyx | last post by:
I tried using urllib.urlopen to open a personalized webpage (my.yahoo.com) but it doesn't work: print urllib.urlopen(http://my.yahoo.com).read() Instead of returning my.yahoo.com, it returns a...
by: johnpollard | last post by:
For some reason this script isn't working and I dont know what it is. I believe the problem lies in the following lines of code since the script works with a different website and username/password...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
by: lllomh | last post by:
How does React native implement an English player?
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.