Basic python arithmetic - division

后端 未结 6 821
眼角桃花
眼角桃花 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:34

    They're integers, so count/per_pages is zero before the functions ever get to do anything beyond that. I'm not a Python programmer really but I know that (count * 1.0) / pages will do what you want. There's probably a right way to do that however.

    edit — yes see @mipadi's answer and float(x)

提交回复
热议问题