在python的Cypher查询中传递变量

时间:2018-12-25 16:14:44

标签: python flask neo4j cypher

我有2个变量

 name='name1234'
 age='21'

和一个neo4j密码查询

query33= 'CREATE (k:user { Username: @name, Userage: '@age' })'

我如何传递两个变量?

1 个答案:

答案 0 :(得分:0)

您可以通过以下格式传递它:https://docs.python.org/3.4/library/functions.html#format

query33= "CREATE (k:user {{ Username: {name}, Userage: '{age}' }})".format(name='name1234', age=21)
query33
"CREATE (k:user { Username: name1234, Userage: '21' })"