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

时间:2013-12-26 13:29:47

标签: graph ontology rdflib

我有以下资源: http://test.com/domainOnt/email#plans@plan.com

与在RDFLib中一样,当您在图形中搜索它时,它会返回一个URIRef对象。我想从对象中删除命名空间,使其成为plans@plan.com

感谢任何帮助

1 个答案:

答案 0 :(得分:2)

RDFLib中的URIRef对象是unicode对象,并且具有所有unicode对象方法,如split。如果所有类名都使用“#”与命名空间分隔,则以下内容将起作用。

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

question and answer与您的非常相似。