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')
Writing RDF/XML file from rdf Triples in rdflib