Вопрос

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