代码拉取完成,页面将自动刷新
from py2neo import Graph, NodeMatcher, RelationshipMatcher
# 连接到Neo4j数据库
graph = Graph("http://localhost:7474", auth=("neo4j", "123456"))
# 导出节点和关系的内容
def export_data():
# 打开文件
with open("1.txt", "w") as file:
node_matcher = NodeMatcher(graph)
relationship_matcher = RelationshipMatcher(graph)
# 导出节点
nodes = node_matcher.match()
for node in nodes:
file.write("%s" % str(node))
# 导出关系
relationships = relationship_matcher.match()
for relationship in relationships:
# print(str(relationship))
file.write(str(relationship))
# 导出数据
export_data()
# from py2neo import Graph
# # 连接到Neo4j数据库
# graph = Graph("http://localhost:7474", auth=("neo4j", "123456"))
# # 导出节点和关系的内容,并将关系写入文件
# def export_data():
# # 打开文件
# with open("1.txt", "w") as file:
# relationship_list = []
# # 导出节点
# nodes = graph.nodes
# for node in nodes:
# file.write("%s" % node)
# # 导出关系
# relationships = graph.relationships
# for relationship in relationships:
# relationship_list.append(str(relationship))
# # 写入关系到文件
# file.write("\n".join(relationship_list))
# # 导出数据
# export_data()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。