gpt4 book ai didi

python - 如何让python返回 float ?

转载 作者:太空宇宙 更新时间:2023-11-03 12:19:51 25 4
gpt4 key购买 nike

如果我写 1/2(而不是 1.0/2.0),我希望 python 返回 0.5。如何让 python 返回 float ?(我尝试使用 getcontext().prec 形式的十进制模块)

谢谢

爱丽儿

最佳答案

使用这个,或者切换到 Python 3.0+

from __future__ import division

关于python - 如何让python返回 float ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2341771/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com