小编fal*_*utx的帖子

Python float __setformat__?

我有一个问题,我需要得到一个正确的浮点数小数点后18位.当我使用默认浮点数(数字)时,它只给我12个小数位.

然后我做了dir(浮动)

    ['__abs__', '__add__', '__class__', '__coerce__', '__delattr__', '__div__', '__divmod__', '__doc__',
 '__eq__', '__float__', '__floordiv__', '__format__', '__ge__', '__getattribute__', '__getformat__',
 '__getnewargs__', '__gt__', '__hash__', '__init__', '__int__', '__le__', '__long__', '__lt__', '__m
od__', '__mul__', '__ne__', '__neg__', '__new__', '__nonzero__', '__pos__', '__pow__', '__radd__', '
__rdiv__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rmod__', '_
_rmul__', '__rpow__', '__rsub__', '__rtruediv__', '__setattr__', '__setformat__', '__sizeof__', '__s
tr__', '__sub__', '__subclasshook__', '__truediv__', '__trunc__', 'as_integer_ratio', 'conjugate', '
fromhex', 'hex', 'imag', 'is_integer', 'real']
Run Code Online (Sandbox Code Playgroud)

该块中有一些叫做__setformat__的东西.有什么用?以及如何使用它进行浮点精度设置?

我使用的是python 2.7.5 x64.

python floating-point python-2.7

-1
推荐指数
2
解决办法
268
查看次数

标签 统计

floating-point ×1

python ×1

python-2.7 ×1