慕姐8265434
可以向模板(template)传递多个参数或者把全部的本地参数传递给template:1. 传递多个参数给template,直接将参数放在render_template()函数里面,参数间用逗号隔开:@app.route('/')def index():content = '.....'user='Micheal'return render_template('index.html', var1=content, var2=user)template中可以直接使用{{var1}}和{{var2}}直接操作变量。2. 传递全部的本地变量给template,使用**locals():@app.route('/')def index():content = '.....'user='Micheal'return render_template('index.html', **locals())template中可以直接使用{{content}}和{{user}}直接操作变量。