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

时间:2024-04-25 17:37:44
在 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>

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


{{字符串|lower}}

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

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


2020-05-14