这段代码的有效语法是什么?

2024-04-25 02:02:31 发布

您现在位置:Python中文网/ 问答频道 /正文

@app.route("/login",methods=["POST","GET"])
def login():
if request.method == 'POST':
session.pop('user_id',none)
userrnam = request.form.get("username")
palavrapass= request.form.get("password")

usere = users.query.filter_by(username=userrnam).first()
if usere and palavrapass == usere.password:
    session.['User_id'] = usere.id
    return redirect(url_for('profile'))
pass
return render_template("login.html")

When I run the program, it tells me that this line of code

session.['User_id'] = usere.id

is invalid syntax. If this is wrong syntax, than which is the correct way?