Redland python bindings.Unexpected print ot triples
I have the below code in python:
import RDF
parser = RDF.Parser()
model=RDF.Model()
stream=parser.parse_into_model(model,"file:./zoo/zoo.rdf")
list 开发者_开发百科= []
for triple in model:
print triple.subject, triple.predicate, triple.object
list.append([ triple.subject , triple.predicate , triple.object ] )
print len(list)
for k in list:
print k
at the first loop the statements of my rdf are printed correctly.But at the 2nd statement the addresses of each element is printed out:
< RDF.Node object at 0x7eec158c>, < RDF.Node object at 0x7eec1b2c>, < RDF.Node object at
0x7eec1b8c>
< RDF.Node object at 0x7eec146c>, < RDF.Node object at 0x7eec606c>, < RDF.Node object at 0x7eec612c>
. . .
Why this is happened instead of printing the statements?
Try
for k in list:
print map(str, k)
Try
for k in list:
print str(k)
精彩评论