因此,如果我运行:
a = b / c
并得到结果
1.2234
我如何分离它,这样我可以:
a = 1
b = 0.2234
最佳答案
>>> from math import modf
>>> b,a = modf(1.2234)
>>> print ('a = %f and b = %f'%(a,b))
a = 1.000000 and b = 0.223400
>>> b,a = modf(-1.2234)
>>> print ('a = %f and b = %f'%(a,b))
a = -1.000000 and b = -0.223400