简体   繁体   English

用py2neo填充neo4j并使用cypher查询时的编码问题

[英]encoding issues when populating neo4j with py2neo and querying with cypher

I used py2neo to add nodes and relations in neo4j. 我使用py2neo在neo4j中添加节点和关系。

created with: 创建于:

asno, = graphDB.create({"name":"ASNO:"+fields[8], "ASNO":fields[8]});
asno.add_labels("Network", "ASNO", continent);

printing in python: ASNO : 38023 用python打印:ASNO:38023


However, when I query with cypher: 但是,当我用密码查询时:

Query 1. match (n) where n.name = "ASNO:38023" return n; 查询1. match(n)其中n.name =“ ASNO:38023”返回n;

There are no returns; 没有回报;

Query 2. match (n) where n.name = "ASNO:\3\8\0\2\3\" return n; 查询2.匹配(n),其中n.name =“ ASNO:\\ u00003 \\ u00008 \\ u00000 \\ u00002 \\ u00003 \\ u0000”返回n;

The following is returned. 返回以下内容。

{ "table": [ { "n": { "name": "ASNO:\3\8\0\2\3\", "ASNO": "\3\8\0\2\3\" } } ], "graph": { "nodes": [ { "name": "ASNO:\3\8\0\2\3\", "ASNO": "\3\8\0\2\3\", "id": "906", "type": "Network" } ], "edges": [] }, "labels": [ "Network" ] }


I need help in having the query run in Query 1 method. 我需要在查询1方法中运行查询的帮助。 Thanks and Appreciation for your help. 感谢您的帮助。

Try forcing your name value to be ASCII using the str() function. 尝试使用str()函数将名称值强制为ASCII。

nameval = str("ASNO:" + fields[8])

asno, = graphDB.create({"name":nameval, "ASNO":fields[8]})

asno.add_labels("Network", "ASNO", continent)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM