Python 2.7 + Flask TypeError: 'unicode' object is not callable
Python 2.7 + Flask TypeError: 'unicode' object is not callable
我正在尝试连接 2 个 unicode 字符串,但出现错误。
代码:
@app.route('/', methods = ['GET','POST'])
def index():
form = forms.MyForm()
rtv = []
text = u''
if request.method == 'POST':
lat = form.latitude.data
lng = form.longitude.data
rds = form.radio.data
sql = text("select place, tweet_id, tweet_text from tweets where ST_DistanceSphere(geom, ST_MakePoint(" + lng + ","+ lat +")) <= "+ rds +" * 1609.344 * 0.62137;")
result = db.engine.execute(sql)
for row in result:
text = text+row[2] #row[2] is a unicode string
rtv.append([row[0],row[1],row[2]])
print text
return render_template('base.html', form = form, rtv = rtv, text = text)
您在语句 sql = text("...")
之前定义 text = u''
。所以例外是'unicode' object is not callable
。
我正在尝试连接 2 个 unicode 字符串,但出现错误。
代码:
@app.route('/', methods = ['GET','POST'])
def index():
form = forms.MyForm()
rtv = []
text = u''
if request.method == 'POST':
lat = form.latitude.data
lng = form.longitude.data
rds = form.radio.data
sql = text("select place, tweet_id, tweet_text from tweets where ST_DistanceSphere(geom, ST_MakePoint(" + lng + ","+ lat +")) <= "+ rds +" * 1609.344 * 0.62137;")
result = db.engine.execute(sql)
for row in result:
text = text+row[2] #row[2] is a unicode string
rtv.append([row[0],row[1],row[2]])
print text
return render_template('base.html', form = form, rtv = rtv, text = text)
您在语句 sql = text("...")
之前定义 text = u''
。所以例外是'unicode' object is not callable
。