【问题标题】:How to display two digits after the decimal point on my template?如何在我的模板上显示小数点后两位?
【发布时间】:2015-05-06 23:13:50
【问题描述】:

我有两个问题 如何在我的模板上显示小数点后两位? 以及如何在我的 3 位数字后面加上逗号,例如,如果我有 156200,我会在模板中显示 156.200

【问题讨论】:

标签: python django django-templates


【解决方案1】:

您可以在 views.py 操作中创建它并将其设置为您的模板 你可以做一些这样的事情:-

from __future__ import division
num = 156200/1000

或者在你的模板中使用 JavaScript 来实现

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-12-05
    • 1970-01-01
    • 2018-03-02
    • 2011-05-27
    • 1970-01-01
    • 2022-12-05
    • 2012-05-22
    • 1970-01-01
    相关资源
    最近更新 更多