有些代码可以被忽略,我试图把str变成int,而这样做我似乎得到了这个错误。 ' INT'对象不可调用
llb和lw在本节的代码中没有提到代码中的任何其他地方。它是第一次也是唯一一次。
我现在一直在为此而烦恼,似乎无法解决这个问题。此错误的任何其他内容似乎都与我的错误相同。
llb通常设置为一个简单的东西,如帖子
@app.route('/printlab', methods=['POST'])
def printlab():
if request.method == 'POST':
lfname = request.form['first_name']
llname = request.form['last_name']
lstate = request.form['state']
lcity = request.form['city']
laddress = request.form['shipping_address']
lzip = request.form['zip']
llb = request.form['lbs']
loz = request.form['ozs']
lw = (int(llb)*16)
return lw
编辑:在
下面添加了错误Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1997,
in __call__
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1985,
in wsgi_app
response = self.handle_exception(e)
File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1540,
in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1615, in full_dispatch_request
return self.finalize_request(rv)
File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1630, in finalize_request
response = self.make_response(rv)
File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1740, in make_response
rv = self.response_class.force_type(rv, request.environ)
File "/usr/local/lib/python2.7/site-packages/werkzeug/wrappers.py", line 921, in force_type
response = BaseResponse(*_run_wsgi_app(response, environ))
File "/usr/local/lib/python2.7/site-packages/werkzeug/wrappers.py", line 59, in _run_wsgi_app
return _run_wsgi_app(*args)
File "/usr/local/lib/python2.7/site-packages/werkzeug/test.py", line 923, in run_wsgi_app
app_rv = app(environ, start_response)
TypeError: 'int' object is not callable
答案 0 :(得分:2)
视图函数应该返回模板渲染调用,重定向或其他类型的HTML响应。你的函数返回一个普通的整数。
此返回值正被传递到Flask框架,该框架无法处理它。