Array of hash table
Dave Angel
davea at davea.name
Fri Jan 9 02:30:53 EST 2015
On 01/09/2015 02:17 AM, jyoti690saini at gmail.com wrote:
> Hello,
>
> Can any one tell me how to create
> graph={
> "nodes": [
> {
> "id": "n0",
> "label": "A node",
> "x": 0,
> "y": 0,
> "size": 3
> },
> {
> "id": "n1",
> "label": "Another node",
> "x": 3,
> "y": 1,
> "size": 2
> },
> {
> "id": "n2",
> "label": "And a last one",
> "x": 1,
> "y": 3,
> "size": 1
> }
> ],
> "edges": [
> {
> "id": "e0",
> "source": "n0",
> "target": "n1",
> "label" : "dfghujikoi"
> },
> {
> "id": "e1",
> "label" : "dfghujikoi",
> "source": "n1",
> "target": "n2"
>
> },
> {
> "id": "e2",
> "source": "n2",
> "target": "n0",
> "label" : "dfghujikoi"
> }
> ]
> }
>
> using python?
>
> its like a hash table and value is an array of hash table ?
> I tried but it was giving error of "List out of index" .
>
You just did. If you'd like to see it, add a print(graph) . What's
your real question?
BTW, in Python, it's called a dict, not a hash table. But you did it
correctly.
And if you want to fetch a particular element, use:
print(graph["edges"][1]["id"])
--
DaveA
More information about the Python-list
mailing list