[英]py2neo exists return wrong result
when i use py2neo exists() i get a wrong result,i think the result will be 'True',but it give a 'False' when i use 当我使用py2neo exist()时,我得到一个错误的结果,我认为结果将为“ True”,但是当我使用时,它给出一个“ False”
c = Node("Person", name="Alice")
g.exists(c)
it return a 'False', but when i change like this 它返回一个“ False”,但是当我这样改变时
c = a
g.exists(c)
i will get a 'True' why? 我会得到一个“正确”的原因吗?
from py2neo import Graph,Node,Relationship
g = py2neo.Graph('http://localhost:7474', user='yudeng',password='yudeng')
a = Node("Person", name="Alice")
b = Node("Person", name="Bob")
ab = Relationship(a, "KNOWS", b)
print(a)
g.create(a)
g.create(b)
g.create(ab)
c = Node("Person", name="Alice")
g.exists(c)
When you just state 当你只说
c = Node("Person", name="Alice")
g.exists(c)
Result: 结果:
False
without 无
g.create(c)
Then the node does not exist because you did not created the node in the graph. 然后该节点不存在,因为您没有在图中创建该节点。
This is what you executed to get a True: 这是您为获得True而执行的操作:
a = Node("Person", name="Alice")
b = Node("Person", name="Bob")
ab = Relationship(a, "KNOWS", b)
print(a)
g.create(a)
g.create(b)
g.create(ab)
c = a
g.exists(c)
Because then c equals to a that means the node exists => Node("Person", name="Alice") can then be found with a and c. 因为然后c等于a,这意味着该节点存在=>然后可以通过a和c找到Node(“ Person”,name =“ Alice”)。
Result: 结果:
(:Person {name: 'Alice'})
True
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.