Django学习路24_乘法和除法

urls 中

url(r'getnum',views.getnum)

views.py 中添加对应的函数

def getnum(request):
    num = 5
    context_num = {
        'num':num
    }
    return render(request,'num_ys.html',context=context_num)

html 中代码

<body>
{# 乘法 #}
<h2> {{num}} 当前的值</h2>
<h3>进行运算后的值 : {% widthratio num 1 5  %}</h3>

{# 除法 #}
<h2> {{num}} 当前的值</h2>
<h3>进行运算后的值 : {% widthratio num 5 1 %}</h3>

</body>


{%widthratio 数 分母 分子 %}

2020-05-14

 

posted @ 2020-05-14 19:41  CodeYaSuo  阅读(336)  评论(0编辑  收藏  举报