I have the following codes:
name = [str(s) for s, in graph.query('''
SELECT ?lbl
WHERE {
<http://www.wikidata.org/entity/Q59692464> <http://www.wikidata.org/prop/direct/P1657> ?obj .
?obj rdfs:label ?lbl .
}
''')]
I want to pass the two values<http://www.wikidata.org/entity/Q59692464>
and <http://www.wikidata.org/prop/direct/P1657>
as variables ?mov
and ?rel
.
I tried to use %s but got an error:
name = [str(s) for s, in graph.query('''
SELECT ?lbl
WHERE {
<'%s'> <http://www.wikidata.org/prop/direct/P1657> ?obj .
?obj rdfs:label ?lbl .
}
'''%mov)]
TypeError: unsupported operand type(s) for %: 'SPARQLResult' and 'str'
What I want is something like this:
name = [str(s) for s, in graph.query('''
SELECT ?lbl
WHERE {
?mov ?rel ?obj .
?obj rdfs:label ?lbl .
}
''')]
Thanks a lot for your help!