环境: python3.8 flask2.0
最简单的 flask 代码:
from flask import Flask, session, render_template
app = Flask(__name__)
app.config['SECRET_KEY'] = 'fasfsae'
@app.route("/")
def tt():
session['user'] = 'name'
return 'render_template("index.html")'
app.run(127.0.0.1,debug=True)
运行时候提示错误:
File "D:/python/flask_test/flask-test.py", line 10, in tt
session['user'] = 'name'
TypeError: 'function' object does not support item assignment
我type(session) session 为 function
百思不得姐 请各位帮忙解答 万分感谢 万分感谢