string - 谁能告诉下面的代码有什么问题,我收到以下错误:TypeError TypeError:字符串索引必须是整数
问题描述
谁能告诉我下面的代码有什么问题,我收到以下错误: TypeError TypeError: string indices must be integers 特别抱怨这两行:
@main.route('/idm_prototype', methods=['GET', 'POST'])
def search(to_find=None):
if request.method == "POST":
postcodevar = request.form['postcodevar']
print("Assigning SQl statement to a postgreSQL variable")
postgreSQL_select_Query_2 = ("SELECT DISTINCT gss, str(gss), description,
str(description), \n"
"postcode str(postcode) FROM postcodelatlng pt, gss.shapes g WHERE st_contains("
"geom,pos) AND %(postcode)s~* \n "
" ukpostcode_exact_re() LIMIT 50"), {'postcode': postcodevar}
LIMIT 50", {'postcode': postcodevar}
for s in range(len(postgreSQL_select_Query_2)):
if postgreSQL_select_Query_2[s]["gss"] == to_find:
cursor.execute("{},{},{}.".format(postgreSQL_select_Query_2[s]["gss"],
postgreSQL_select_Query_2[s]["description"], postgreSQL_select_Query_2[s]
["postcode"]))
print("Selecting rows from mobile table using cursor.fetchall")
records = cursor.fetchall()
return render_template('idm_prototype.html', data=records)
解决方案
推荐阅读
- python-3.x - Tensorflow-Serving :requests.exceptions.HTTPError: 400 Client
- python - 在 seaborn 上的图像上绘制热图
- flutter - Flutter 应用中的 PlatformException(ad_not_loaded,奖励视频显示失败,未加载广告,null)
- elasticsearch - Kibana Timelion 没有从索引中绘制数据
- c++ - 简单提升序列化中的未定义参考错误
- javascript - 滚动时更新 HTML 画布高度
- django - 如何创建重用模型唯一键的序列化程序?
- python - 使用正则表达式清理熊猫系列
- c - 如何在 C 中用新的/更新的像素阵列更新/替换 SDL Surface 像素阵列?
- swift - 使用 Tab Bar Swift 点击时 TableView 未加载