from rdflib import Graph, URIRef, Literal g = Graph() result = g.parse("http://www.w3.org/2000/10/swap/test/meet/blue.rdf") print("graph has %s statements." % len(g)) for s, p, o in g: if (s, p, o) not in g: s = g.serialize(format='nt') sorted(g) == [ (URIRef(u'http://meetings.example.com/cal#m1'), URIRef(u'http://www.example.org/meeting_organization#homePage'), URIRef(u'http://meetings.example.com/m1/hp')), ] g.serialize(destination=None, format='xml', base=None, encoding=None, **args) | If destination is None serialize method returns the serialization as a | string. Format defaults to xml (AKA rdf/xml). | Format support can be extended with plugins, | but 'xml', 'n3', 'turtle', 'nt', 'pretty-xml', 'trix', 'trig' and 'nquads' are built in. g.set( (s,p,o)=remove(s,p,?) e insere (s,p,o) g.subject_objects( p)=[(?s,?o) for (?s,p,?o) in g] g.subject_predicates( o) =[(?s,?p) for (?s,?p,o) in g] g.subjects( p, o) [s for (?s,p,o) in g] g.objects( s, p) [o for (s,p,?o) in g] g.predicates( s, o) [p for (s,?p,o) in g] g.add( (s,p,o)) g.add((URIRef('http://h.c/a'),URIRef('http://w.c/b'), Literal('foo'))) for a in g.triples((None,None,None)): Literal(lexical_or_value, lang=None, datatype=None, normalize=None) RDF.nil RDF.first RDF.rest rdfs.class a=BNode('abc') b=URIRef("http://a.b.c/d") g.namespaces() OWL = Namespace('http://www.w3.org/2002/07/owl#') RDF = rdf.namespace.ClosedNamespace('http://www.w3.org/1999/02/22-rdf-... RDFS = rdf.namespace.ClosedNamespace('http://www.w3.org/2000/01/rdf-sc... XSD = Namespace('http://www.w3.org/2001/XMLSchema#') g.transitiveClosure( func, arg, seen=None) g.transitive_objects(s,p) g.transitive_subjects(p,o) g.value(s,p,o) #one of them is None === g.preferredLabel( subject, lang=None, default=None, labelProperties=(rdflib.term.URIRef('http://www.w3.org/2004/02/skos/core#prefLabel'), rdflib.term.URIRef('http://www.w3.org/2000/01/rdf-schema#label'))) skos:prefLabels over rdfs:labels. In case at least Return [(labelProp, label)] labelProp is either skos:prefLabel or rdfs:label. === from rdflib import ConjunctiveGraph, URIRef, RDFS, Literal from rdflib.namespace import SKOS , XSD from pprint import pprint | >>> g = ConjunctiveGraph() === g.bind( prefix, namespace, override=True) Bind prefix to namespace example: graph.bind('foaf', 'http://xmlns.com/foaf/0.1/') === g.open( configuration, create=False) | Open the graph store | | Might be necessary for stores that require opening a connection to a | database or acquiring some resource. g.close() === g.query(