在 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