number_format
该number_format过滤器格式的数字
参数:
decimal: 要显示的小数点数
decimal_point: 用于小数点的字符
thousand_sep: 用于千位分隔符的字符
举例:
{{ 9800.333|number_format(2, '.', ',') }}{# outputs : 9,800.33 #}
如果格式化负数的时候要注意要加括号
{{ -9800.333 |number_format(2, '.', ',') }} {# outputs : -9 #}
{{ (-9800.333)|number_format(2, '.', ',') }} {# outputs : -9,800.33 #}