2

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

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

任何帮助表示赞赏

4

1 回答 1

3

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

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

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

于 2014-01-02T14:42:55.267 回答