我有一个问题,我需要将浮点数正确到小数点后 18 位。当我使用默认浮点数(数字)时,它只给我 12 位小数。
然后我做了 dir(float)
['__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']
在那个块中有一个叫做 __setformat__ 的东西。它的用途是什么?以及如何将其用于浮点精度设置?
我正在使用 python 2.7.5 x64。