Python 表单中的打印值始终显示空白值
我试图打印出表单字段的值,以便在比较中使用该值之前进行一些调试。但是值总是空的。为什么这不起作用Python 表单中的打印值始终显示空白值,python,flask,Python,Flask,我试图打印出表单字段的值,以便在比较中使用该值之前进行一些调试。但是值总是空的。为什么这不起作用 @app.route('/', methods=['GET', 'POST']) def login(): username = '' password = '' if request.method == 'GET': return render_template('test.html') elif request.method == 'POST':
@app.route('/', methods=['GET', 'POST'])
def login():
username = ''
password = ''
if request.method == 'GET':
return render_template('test.html')
elif request.method == 'POST':
username == request.form.get('username')
password == request.form.get('password_data')
print password
测试
您在密码字段中使用了相等==而不是赋值=。因此,您实际上不会从分配给它的初始空字符串更改密码
password = request.form.get('password_data')
print(password)