使用 neo4jrestclient 进行匹配

from neo4jrestclient import client

q = 'MATCH (u:User)-[r:likes]->(m:language) WHERE u.name="Marco" RETURN u, type(r), m'

db 如上所定义

results = db.query(q, returns=(client.Node, str, client.Node))

打印结果

for r in results:
print("(%s)-[%s]->(%s)" % (r[0]["name"], r[1], r[2]["name"]))

输出:

(Marco)-[likes]->(C++)
(Marco)-[likes]->(Python)