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
本文来自博客园,作者:CodeYaSuo,转载请注明原文链接:https://www.cnblogs.com/hany-postq473111315/p/12891253.html