NameError: name 'escape' is not defined

昨天在學習flask的時候,發現這個問題

官方提供的代碼:

@app.route('/user/<username>')
def show_user_profile(username):
    # show the user profile for that user
    return 'User %s' % escape(username)

說是escape沒有定義,所以在之前記得導入就好了

from flask import Flask, escape

 

就可以正常運行了

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章