如何在 py2neo 中检索节点的 属性 值

How to retrieve property values of a node in py2neo

我正在创建一个几何形状和节点的图形数据库,其中包含一个名为 "type" 的 属性 以指示该形状是三角形、圆形还是 square.I 要检索每个节点的类型,并在 IF 条件下使用它,如下所示。

Results = g.run("START n=node(*)  RETURN n.type as type")
for Result in Results:
     if Result.type == 'TRINGLE':
        print("It is a Triange")
     elif Result.type == 'CIRCLE':
         print("It is a Circle")
     else:
        print("It is a Square")

当 运行 此代码显示如下错误时 - 如果 Result.type == 'TRINGLE': AttributeError: 'Record' 对象没有属性 'type'

谁能告诉我有什么办法可以解决这个问题。

您需要 record["type"] 而不是 record.type