0

I'm trying to create http post data to be sent out. I normally use a dictionary for this. But normally all fields are different.

The new server expects 3 entries with the same name but different value as below.

But python dictionaries doesn't seem to like the same key name being used for the 3 different values. So what is the best way to do what I want?

    data = urllib.parse.urlencode({
        'val1':'1',
        'val1':'2',
        'val1':'3', 
    })
    ....
    response = self.opener.open(url, data) # data only seem to contain 'val1':'3'

I've read about returning an array as the value with the 3 different arguments ie: {'val1':['1','2','3']} but will the url opener know to split that out to three different fields?

user1144251
  • 327
  • 1
  • 3
  • 12
  • possible duplicate of [Python Dictionary w/ 2 Keys?](http://stackoverflow.com/questions/9413306/python-dictionary-w-2-keys) – vaultah Jul 05 '14 at 03:50
  • but will the url opener know to split that out to three different fields if i do: {'val1':['1','2','3']} – user1144251 Jul 05 '14 at 03:56
  • 1
    Ok found my answer: http://stackoverflow.com/questions/18201752/sending-multiple-values-for-one-name-urllib2 – user1144251 Jul 08 '14 at 02:36

0 Answers0