You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

13 lines
451 B

5 months ago
from py2neo import Graph, Node
# 使用新版连接协议注意端口改为7687
db = Graph("neo4j://127.0.0.1:7687", auth=("neo4j", "DsideaL4r5t6y7u"))
# 更现代的写法(使用上下文管理器自动提交)
node_1 = Node("英雄", name="张无忌")
node_2 = Node("英雄", name="杨逍", power=100)
node_3 = Node("派别", name="明教")
db.create(node_1 | node_2 | node_3) # 使用 | 运算符组合节点
print(node_1)