鍍金池/ 問答/Python/ python flask 報錯: TypeError: 'int' object

python flask 報錯: TypeError: 'int' object is not callable

python + flask,希望能返回循環(huán)次數(shù),報錯:

代碼:

app=Flask(__name__)  
@app.route('/')
def index():
    hah = 0
    print('hello word!')
    return hah

錯誤提示:

 TypeError: 'int' object is not callable

請問是什么原因? 百度了一圈,都是因為 變量名和系統(tǒng)變量沖突,但這里的變量并不存在沖突的情況。

回答
編輯回答
雅痞

hah是個int型,顯然不可調(diào)用啊

2017年10月26日 12:25
編輯回答
孤巷

上面的回答是對的??梢赃@樣修改。

app=Flask(__name__)  
@app.route('/')
def index():
    hah = 0
    print('hello word!')
    return str(hah)
2018年5月27日 17:49