模板语法
作者:互联网
1.深度查询:
def index(request): name = "root" age = 13 sex = True lve = ["swimming","shopping","coding",] bookinfo = {"id":10,"price":9.0} return render(request,"index.html",locals())
//locals()代表传入的所有变量
#模板代码template/index.html: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <a> hi {{name}}</a> //普通变量取值 <a>lve :{{lve.1}}</a>//通过局点符取出列表中的第二个元素 <a>lve :{{bookinfo.id}}</a> //通过句点符取出字典中id的 值 </body> </html>
//句点符表示深度查询
标签:index,lve,语法,html,句点,locals,id,模板 来源: https://www.cnblogs.com/jxyl/p/16421660.html