我正在尝试neoj4网站上的Python驱动程序示例。问题是我不断收到IndentionError
我尝试了空格与制表符。无法解决。在这个简单的文件中,我做了一个:
def print_this(str):
print(str)
return;
print_this('a simple test')
效果很好。
from neo4j.v1 import GraphDatabase
uri = "bolt://localhost:7687"
driver = GraphDatabase.driver(uri, auth=("neo4j", "password"))
def print_friends_of(tx, name):
for record in tx.run("MATCH (a:Person)-[:KNOWS]->(f) "
"WHERE a.name = {name} "
"RETURN f.name", name=name):
print(record["f.name"])
with driver.session() as session:
session.read_transaction(print_friends_of, "Alice")
错误
print(record["f.name"])
^
IndentationError: expected an indented block
有人知道吗?
坦克
答案 0 :(得分:0)
带有声明
for record in tx.run("MATCH (a:Person)-[:KNOWS]->(f) "
"WHERE a.name = {name} "
"RETURN f.name", name=name):
您正在开始一个新的for
循环。您的下一行应缩进,使其位于for
循环中。更改为
for record in tx.run("MATCH (a:Person)-[:KNOWS]->(f) "
"WHERE a.name = {name} "
"RETURN f.name", name=name):
print(record["f.name"]) #note how it is indented to be inside of the for loop