python - page_not_found(e)中e代表的是什么?
怪我咯
怪我咯 2017-04-18 09:42:05
0
4
1616

《Flask web development》 3.3自定义错误页面

@app.errorhandler(404)
def page_not_found(e):
    return render_template('404.html'), 404
    

使用errorhandler装饰器,其中page_not_found(e)是继承与e的子类么?这个e代表的是什么意思?

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(4)
阿神

From the definition, e is the parameter of page_not_found, and e may be an instance of Exception, which can be identified by
type(e).

小葫芦

You will know if you try without writing e. The foundation is not solid. . .

迷茫

I saw this place too. See it from this Chinese document

An error handler is a function similar to a view function, but it is executed when an error occurs, and the error is passed in as a parameter. Generally the error will be an HTTPException , but in some cases it will be other errors: the internal server's error handler will be executed with the actual code error being caught as a parameter.

This little e can be an error caused by HTTP or other errors (thank you for the reminder).

洪涛

e is an error object. The error information is stored in this variable, similar to:

try:
    eat()
except Exception as e:
    print(e)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template