1
from py2neo import Graph, Node, Relationship
l=["Vipul", "Vithal", "Yoga"]
hasage=["hasAge", "hasAge", "hasAge"]
age=[24,31,26]

g = Graph(password="Abc123")

tx = g.begin()
for item in l:
    Vithal = Node("item", name=l[l.index(item)], hasage[l.index(item)]=age[l.index(item)])
    tx.create(Vithal)
    tx.commit()

我收到一个错误:

Vithal = Node("item", name=l[l.index(item)], hasage[l.index(item)]=age[l.index(item)])

SyntaxError:关键字不能是表达式

我正在尝试使用预定义列表中的值为节点创建属性名称。

4

0 回答 0