简体   繁体   中英

How can I extract information from a recordList returned as node in python using py2neo?

My question is when I have my result as recordList and returned values are nodes then how can I extract information like properties of any particular node from recordList data structure?

results = graph.cypher.execute("MATCH (n:Person) return n")
for index in range(len(results)):
        print results[index].n

Returned:

(n3:Person {birthday:"17/8/2001",name:"John",sex:"male"})
(n4:Person {birthday:"17/8/2001",name:"John",sex:"male"})
(n5:Person {birthday:"17/8/2001",name:"John",sex:"male"})

How can I extract name, sex properties out of returned recordList or Only way is to write cypher that return name and sex of all nodes?

A node has .properties :

results = graph.cypher.execute("MATCH (n:Person) RETURN n LIMIT 10")

for row in results:
    properties = row.n.properties
    print(properties['name'])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM