filesizeformat过滤器不起作用? [英] filesizeformat filter not working?
本文介绍了filesizeformat过滤器不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图将字节大小转换为以易于理解的格式描述的字符串:
I'm trying to simply render a size in bytes to a string which describes it in human-readable format:
$ python -c "import jinja2 ; print jinja2.Template(\"{{ bytes|filesizeformat }}\").render(bytes=1572864)"
0.0 MB
不幸的是,我总是得到0.0 MB
作为结果.为什么我没有真正的价值?
Unfortunately, I always get 0.0 MB
as the result. Why am I not getting a real value?
推荐答案
filesizeformat
过滤器为但是,此修复非常简单,仅涉及两行代码,您可以自己实现.在此处.
The fix, however, is really simple, involves only two lines of code, and you can implement it yourself. See here.
这篇关于filesizeformat过滤器不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文