使用py2neo创建节点时出错:关键字不能是表达式

2024-10-06 09:40:51 发布

您现在位置:Python中文网/ 问答频道 /正文

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: keyword can't be an expression

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


Tags: namefromimportnodeageindexitemgraph