Flask render_template 字典传参

python学习网 2017-12-24 09:52:01
        return render_template('regist.html',username='abc',age=18,sex='')

        # context{
        #     'username':'abc',
        #     'age':18,
        #     'sex':'男'
        # }
        #return render_template('regist.html',**context)

2

        # return render_template('regist.html',username='abc',age=18,sex='男')
                #request.args['username']

        context{
            'username':'abc',
            'age':18,
            'sex':''
        }
        return render_template('regist.html',**context)

两个星号加字典名

阅读(757) 评论(0)