我有这个注册页面,而在转换所有的参数,当我提出我收到此错误形式:不串中转换的所有参数格式错误:不是字符串格式化
class RegistrationForm(Form):
email = StringField('Email address')
password = PasswordField('password')
name = StringField('Name')
@app.route('/register/', methods=['GET', 'POST'])
def register():
try:
form = RegistrationForm(request.form)
if request.method == 'POST':
email = form.email.data
password = sha256_crypt.encrypt((str(form.password.data)))
con = connection()
cur=con.cursor()
x = cur.execute("SELECT * FROM user WHERE username = (%s)",(thwart(email)))
if int(x) > 0:
return render_template('register.html',form=form)
else:
cur.execute("INSERT INTO user (username,password,name) VALUES (%s,%s,%s);",(thwart(email),thwart(password),thwart(name),))
con.commit()
cur.close()
con.close()
return redirect(url_for('dashboard'))
return render_template('register.html', form=form)
except Exception as e:
return str(e)
发布追踪! – Alex
是逗号错字'thwart(name),))'? – Jens
@Jens我不认为这是,我不得不把这个奇怪的'thwart(名字),''上次我使用'cursor.execute' – pwnsauce