문제

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)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top