RDFLib:从 URIRef 资源中删除命名空间

问题描述 投票:0回答:2

我有以下资源: http://test.com/domainOnt/email#[email protected]

与 RDFLib 一样,当您在图中搜索 this 时,它会返回一个 URIRef 对象。我想从对象中删除命名空间,使其变为[email protected]

如有任何帮助,我们将不胜感激

graph ontology rdflib
2个回答
3
投票
RDFLib 中的 URIRef 对象是 unicode 对象,并且具有所有 unicode 对象方法,例如

split。如果所有类名都用“#”与命名空间分隔,则以下内容将起作用。

resource = URIRef('http://test.com/domainOnt/email#[email protected]') print resource.split('#')[-1]

这个

问题和答案与您的非常相似。


0
投票
您可以简单地执行以下操作:

resource = URIRef('http://test.com/domainOnt/email#[email protected]') result = resource.fragment
    
© www.soinside.com 2019 - 2024. All rights reserved.