Python RDF lib - String value for nodes -


i using rdf lib retrieve values online triple store.

i wondering whats ideal way of turning uriref , literals plain string objects?

for example :

value = g.value(s,foaf.page) 

should using value.n3(), or value.__str__() ? there difference ? on tests, both return sting looks same.

initially storing value, turns out causes problems during string comparisons, store string, there no rdf-related processing after extraction.

if want string contents of literal, use str(value). note throws away information -- datatype , language -- part of rdf model.

for comparison:

lit = rdflib.term.literal('literal\nvalue', lang='en')  print(str(lit)) print('---') print(lit.n3()) 

gives:

literal value --- """literal value"""@en 

it sounds want former.

see pydoc3 rdflib.term.literal.n3 more detail on n3() method returns.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -