I just started using rdflib and I have a program that needs to get the birth date of a person (in this example, Lewis Carroll). My program does that, 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'm sure there's an easy way to print just the date but I haven't been able to find how. if it's of any relevance here's my code:
# open a graph
graph = rdflib.Graph()
# load some data
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)