Django学习路26_转换字符串大小写 upper,lower

在 urls 中注册
url(r'getstr',views.getstr)

在 views.py 中添加函数
def getstr(request):
string = 'abc'
string_2 = 'ABC'
context_str = {
'string':string,
'string_2':'ABC'
}
return render(request,'strs.html',context=context_str)

{{ 字符串 | upper}}

<body>
当前的字符串为 {{ string }}<br/>
字符串大写后为 {{ string | upper }}
</body>


 

{{字符串|lower}}

<body>
当前的字符串为 {{ string_2 }}<br/>
字符串小写后为 {{ string_2 | lower }}
</body>


2020-05-14

 

posted @ 2020-05-14 20:38  CodeYaSuo  阅读(381)  评论(0编辑  收藏  举报