如何让python返回浮点?

ari*_*iel 3 python

如果我写1/2(而不是1.0/2.0),我希望python返回0.5.如何让python返回浮点?(我尝试使用getcontext().prec form decimal module)

谢谢

阿里尔

tru*_*ppo 8

使用它,或切换到Python 3.0+

from __future__ import division
Run Code Online (Sandbox Code Playgroud)