如何使用python在Sparql中插入诸如&、()等特殊字符?

2024-09-30 22:20:02 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用此查询插入数据:

prefix : <http://www.google.com/abc#>

INSERT DATA
{
     
:some&Data a :ABC .
}

但由于&的原因,它正在失败。如何使用特殊字符将数据插入Blazegraph数据库? 相同的查询类似于``

prefix : <http://www.google.com/abc#>

INSERT DATA
{
     
:someData a :ABC .
}
``` passes without errors. I am using python to insert the data, but even in Blazegraph it fails.```

          ERROR: SPARQL-UPDATE: updateStr=prefix : 


INSERT DATA
{
     
:some&Data a :ABC .
}
java.util.concurrent.ExecutionException: org.openrdf.query.MalformedQueryException: Lexical error at line 7, column 7.  Encountered: "D" (68), after : "&"

Tags: 数据comhttpdataprefixabwwwgoogle