如何在Jupyter Notebook上设置Sympy的输出打印精度

问题描述 投票:0回答:1

使用

set_global_settings
我能够使用科学记数法在jupyter笔记本上打印变量:

import sympy as sy
from sympy.printing.str import StrPrinter
StrPrinter.set_global_settings(min=1, max=1)
a=sy.Matrix([189.001234])
a

但是,我仍然需要设置精度:

python jupyter-notebook sympy
1个回答
0
投票

基于使用

.evalf()
中描述的方法回答“在任意精度浮点处评估 sympy 函数”:

import sympy as sy
from sympy.printing.str import StrPrinter
StrPrinter.set_global_settings(min=1, max=1)
a=sy.Matrix([189.001234]).evalf(3)
a
© www.soinside.com 2019 - 2024. All rights reserved.