arr = {'a': [1,2,3], 'b': [6,7,8], 'c': [7,11,2], 'e': [45,2,10]}
res_arr = []
for key, value in arr.items():
for v in value:
for r in res_arr:
if v in r['key']:
r['value'].add(key)
break
else:
res_arr.append({
'key': set([v]),
'value': set([key])
})
res_dict = {}
for r in res_arr:
key = ','.join(r['value'])
if res_dict.get(key):
res_dict[key].extend(r['key'])
else:
res_dict[key] = list(r['key'])
import urllib2
boundary = '85fc538bf62b'
data = """--{0}
Content-Disposition: form-data; name="param_name"
param_value
--{0}--
""".format(boundary)
request = urllib2.Request('http://google.com', data=data, headers={'Content-Type': 'multipart/form-data; boundary={0}'.format(boundary)})
response = urllib2.urlopen(request).read()