How to convert int to float in python?

前端 未结 6 1193
慢半拍i
慢半拍i 2020-12-29 21:39

Does anyone know how to convert int to float.

For some reason, it keeps on printing 0. I want it to print a specific decimal.



        
6条回答
  •  北荒
    北荒 (楼主)
    2020-12-29 22:26

    Other than John's answer, you could also make one of the variable float, and the result will yield float.

    >>> 144 / 314.0
    0.4585987261146497
    

提交回复
热议问题