Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有 rdf 三元组,现在我有兴趣在 Python 中使用 rdflib 生成 RDF/XML 文件。你能给我一些示例代码吗?
谢谢
rdflib文档可能是一个很好的起点,尤其是入门部分。例如:
import rdflib from rdflib.Graph import Graph g = Graph() g.parse("http://www.w3.org/2000/10/rdf-tests/rdfcore/ntriples/test.nt", format="nt") g.serialize("test.rdf", format="rdf/xml")
如果rdf/xml格式未知(取决于rdflib的版本),请改用:
g.serialize("test.rdf", format="pretty-xml")