Basic python arithmetic - division

后端 未结 6 815
眼角桃花
眼角桃花 2021-01-05 14:40

I have two variables : count, which is a number of my filtered objects, and constant value per_page. I want to divide count by per_page and get integer value but I no matter

6条回答
  •  醉话见心
    2021-01-05 15:19

    >>> 10 / float(3)
    3.3333333333333335
    >>> #Or 
    >>> 10 / 3.0
    3.3333333333333335
    >>> #Python make any decimal number to float
    >>> a = 3
    >>> type(a)
    
    >>> b = 3.0
    >>> type(b)
    
    >>> 
    

    The best solution maybe is to use from __future__ import division

提交回复
热议问题