Wie kann ich eine Objekte/dict (?) Eigenschaften und in ein neues Objekt/dict?Gibt es einen Objektspreizungsoperator in Python 2.7x wie in Javascript?
Einfache Javascript:
const obj = {x: '2', y: '1'}
const thing = {...obj, x: '1'}
// thing = {x: '1', y: 1}
Python:
regions = []
for doc in locations_addresses['documents']:
regions.append(
{
**doc, # this will not work
'lat': '1234',
'lng': '1234',
}
)
return json.dumps({'regions': regions, 'offices': []})
wie etwa (https://caisbalderas.com/blog/python-function-unpacking-args-and-kwargs/) – Felipe
'obj. copy() 'und' new_obj.update ({'x': '1'}) ' –