I just started using rdflib, and I have a program that should get the person’s date of birth (in this example, Lewis Carroll). My program does this, however, when I try to print the date it prints: (rdflib.term.Literal ('1832-01-27', datatype = rdflib.term.URIRef (' http://www.w3.org / 2001 / XMLSchema # date ')),)
I am sure there is an easy way to print only the date, but I could not find how to do it. if it matters to my code:
graph = rdflib.Graph()
graph.parse('http://dbpedia.org/resource/Lewis_Carroll')
qres = graph.query(
("PREFIX dbpedia: <http://dbpedia.org/resource/>\n"
"PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>\n"
"PREFIX foaf: <http://xmlns.com/foaf/0.1/>\n"
"SELECT ?birth WHERE {\n"
" ?person dbpedia-owl:birthDate ?birth . \n"
" ?person foaf:givenName ?givenName . \n"
" ?person foaf:surname ?surname . \n"
" VALUES ?person { dbpedia:Lewis_Carroll }\n"
" }"
))
print("the graph has %s statements" % len(qres))
for row in qres:
print(row)
source
share