简体   繁体   English

Python中的rdflib-xsd:没有科学符号的双精度值

[英]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. 我正在寻找有关如何格式化Turtle RDF图,rdflib for Python中的值的提示。 Currently I get values of datatype double displayed in scientific notation: 目前,我得到的数据类型值以科学计数形式显示为double:

-4.28322e-01 ; -4.28322e-01; 5.175547e+01 ; 5.175547e + 01;

and what I need to achieve is 而我需要实现的是

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

Tried normalize=False but still no result. 尝试normalize = False,但仍然没有结果。

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>'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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