我的HTML格式如下:
index.html
{% block form_action %}
<form action = "/login" method = "post">
<p>First Name:</p>
<p><input type = "text" name = "fnm" /></p>
<p>Last Name:</p>
<p><input type = "text" name = "lnm" /></p>
<p><input type = "submit" value = "submit" /></p>
</form>
{% endblock form_action %}
contact.html
{% block form_action %}
<p>Entered Name:</p>
<p> {{ last_name, user_name}} </p>
{% endblock form_action %}
python函数:
@app.route('/login',methods = ['GET','POST'])
def login():
if request.method == 'POST':
fnm = request.form['fnm'] #first name
lnm = request.form['lnm']
return render_template('contact.html',user_name = fnm,last_name = lnm)
它输出下拉菜单,如图所示-我希望显示它时不带括号/引号-任何帮助都非常感谢。image
1条答案
按热度按时间bq3bfh9z1#
谢谢大家的回答我想到了什么
Contact.html
在这里,我更改了模板中的{{last_name}}、{{user_name}}-换句话说,两次单独替换字符串,而不是一次替换元组{{last_name,user_name}}