简体   繁体   中英

rdflib in Python - xsd:double value without scientific notation

I am looking for hints how to format values in a Turtle RDF graph, rdflib for Python. Currently I get values of datatype double displayed in scientific notation:

-4.28322e-01 ; 5.175547e+01 ;

and what I need to achieve is

"-0.428322"^^xsd:double ; "51.75547"^^xsd:double ;

Tried normalize=False but still no result.

Thanks

In [1]: from rdflib import Literal
INFO:rdflib:RDFLib Version: 4.2.1

In [2]: l = Literal(-4.28322e-01)

In [3]: l
Out[3]: rdflib.term.Literal(u'-0.428322', datatype=rdflib.term.URIRef(u'http://www.w3.org/2001/XMLSchema#double'))

In [4]: str(l)
Out[4]: '-0.428322'

In [5]: l.n3()
Out[5]: u'"-0.428322"^^<http://www.w3.org/2001/XMLSchema#double>'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM