I am trying to figure out how to split one dictionary value into 2 separate variables. For example the data I am trying to split is "Example":{"type":"Point","points":[14.670275,121.043955]}. I know that if I wanted the points as a whole it would look like:
VariA = tDict['Example']['points']
But what if I want the two coordicates to be separate variables? Any suggestions?
Thanks.
tDict['Example']['points']
is just a list, so:
p1 = tDict['Example']['points'][0]
p2 = tDict['Example']['points'][1]
Or if you are unkeen about accessing the dictionary twice (not that it matters..):
points = tDict['Example']['points']
p1 = points[0]
p2 = points[1]
Or in a single line and a single access:
p1, p2 = tDict['Example']['points']
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments