查看decimal
模块:
>>> from decimal import *
>>> getcontext().prec = 50
>>> Decimal(1)/Decimal(7)
Decimal('0.14285714285714285714285714285714285714285714285714')
Run Code Online (Sandbox Code Playgroud)
如果您对比decimal
提供的更复杂的操作感兴趣,您还可以查看像bigfloat
, or 之类的库mpmath
(我使用,并且非常喜欢。)