如何让 pythonmpmath.nstr
函数保留所有尾随零mpmath.mpf('0')
?看起来strip_zeros
可选参数不起作用mpmath.mpf('0')
,如下例所示:
Python 3.8.5 (default, Jul 28 2020, 12:59:40)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mpmath
>>> mpmath.dps=30
>>> mpmath.nstr(mpmath.mpf('0'), 10, strip_zeros=False)
'0.0'
>>> mpmath.nstr(mpmath.mpf('1'), 10, strip_zeros=False)
'1.000000000'
>>>