小编Dus*_*ust的帖子

在 python json.dumps 输出中禁用科学记数法

json.dumps 使用科学记数法输出小的浮点数或十进制值,这对于将此输出发送到的 json-rpc 应用程序是不可接受的。

>>> import json
>>> json.dumps({"x": 0.0000001})
'{"x": 1e-07}'
Run Code Online (Sandbox Code Playgroud)

我想要这个输出:

'{"x": 0.0000001}'
Run Code Online (Sandbox Code Playgroud)

最好避免引入额外的依赖项。

python json scientific-notation

10
推荐指数
1
解决办法
4994
查看次数

标签 统计

json ×1

python ×1

scientific-notation ×1