开发者

Redland python bindings.Unexpected print ot triples

开发者 https://www.devze.com 2023-02-11 01:40 出处:网络
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\")

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)
0

精彩评论

暂无评论...
验证码 换一张
取 消