新手一枚,想批量获取一批数据在后台自动生成的 ID 然后做匹配

本来是 for 循环,报错后拆开来还是报错那应该不是我循环的问题了

第一段能正常获取到 ID ,为什么第二段始终返回 NONE

Traceback (most recent call last):

File "add_store.py", line 119, in

main()

File "add_store.py", line 113, in main

print result[0]

TypeError: 'NoneType' object has no attribute '__getitem__'

代码如下:

(删掉了括号里的敏感信息)

hosturl =

posturl =

posturl2 =

cj = cookielib.LWPCookieJar()

cookie_support = urllib2.HTTPCookieProcessor(cj)

opener = urllib2.build_opener(cookie_support, urllib2.HTTPHandler)

urllib2.install_opener(opener)

h = urllib2.urlopen(hosturl)

headers = {}

postData = {}

postData = urllib.urlencode(postData)

request = urllib2.Request(posturl, postData, headers)

response = urllib2.urlopen(request)

conn = MySQLdb.connect()

def main():

i = 31

stname = 'teststore' + str(i)

postData2 = {'storeName': stname}

postData2 = urllib.urlencode(postData2)

request2 = urllib2.Request(posturl2, postData2, headers)

response2 = urllib2.urlopen(request2)

cur = conn.cursor()

cur.execute("select a.store_id from store as a where a.store_name = %s", [stname])

print stname

result = cur.fetchone()

print result[0]

i = 32

stname = 'teststore' + str(i)

postData2 = {'storeName': stname}

postData2 = urllib.urlencode(postData2)

request2 = urllib2.Request(posturl2, postData2, headers)

response2 = urllib2.urlopen(request2)

cur.execute("select a.store_id from store as a where a.store_name = %s", [stname])

print stname

result = cur.fetchone()

print result[0]

cur.close()

conn.close()

if __name__ == '__main__':

main()

MySQL报错113_连接 MySQL 报错'NoneType' object has no attribute '__getitem__'相关推荐

  1. AttributeError: 'NoneType' object has no attribute 'grid'报错解决方案

    1问题描述: 当我们在使用tkinter时经常遇到AttributeError: 'NoneType' object has no attribute 'grid'的报错 2.原因分析: import ...

  2. Scrapy爬虫报错AttributeError: ‘NoneType‘ object has no attribute ‘write‘

    前言 一.报错 AttributeError: 'NoneType' object has no attribute 'write' 二.报错原因 1.piplines文件中的方法不能自定义的呢 开始 ...

  3. AttributeError: 'NoneType' object has no attribute 'split' 报错处理

    报错场景 social_django 组件对原生 django 的支持较好, 但是因为 在此DRF进行的验证为 JWT 方式 和 django 的验证存在区别, 因此需要进行更改自行支持 JWT 方式 ...

  4. Pycharm报错:AttributeError: ‘NoneType‘ object has no attribute ‘_gdal‘的解决办法

    Pycharm报错:AttributeError: 'NoneType' object has no attribute '_gdal'的解决办法 解决办法如下: pycharm找到settings ...

  5. 报错AttributeError: ‘NoneType‘ object has no attribute ‘shape‘

    环境: python3.6.4 opencv3.4.1.15 运行目标跟踪object_tracking文件夹中的mean函数时报错且不显示视频结果 Traceback (most recent ca ...

  6. pyppeteer报错:NoneType‘ object has no attribute ‘goto‘

    使用pyppeteer的过程中发生了报错: 驱动异常-> 'NoneType' object has no attribute 'get' 还有: 驱动异常-> Connection is ...

  7. [报错]深析AttributeError: ‘NoneType‘ object has no attribute ‘xxx‘(持更)

    有相关的博客还要写它的原因在于下面的博客讲了各自的重点.因此,我将深入刨析原因,以及导致该原因出现的几种问题!如果讲解清楚了,请点个赞哦☀️ 参考博文: <AttributeError: 'No ...

  8. 报错分析:【AttributeError: ‘NoneType‘ object has no attribute ‘shape‘】

    -----------------------------------志当高远且脚踏实------------------------------------程_七辰 关于OpenCV读取图片报错 前 ...

  9. python docx设置标题中文字体rPr.rFonts.set(qn(‘w:eastAsia‘),u‘黑体‘),报错‘NoneType‘ object has no attribute ‘set‘

    一.我的代码: 因为要编一个报告自动化生成的代码,所以用了python docx,在设置标题自己写了一段代码,要求将标题设置成:一级标题 黑体 小四 from docx import Document ...

  10. 【全教程】qt连接mysql——从qt编译mysql驱动到qt连接mysql数据库(二、编译连接)

    本篇教程分为三个部分: [全教程]qt连接mysql--从qt编译mysql驱动到qt连接mysql数据库(一.编译连接前准备) [全教程]qt连接mysql--从qt编译mysql驱动到qt连接my ...

最新文章

  1. goodness of classification
  2. SAP云平台的trial账号不具备成员管理的功能
  3. win7和mysql乱码,win7 mysql中文乱码怎么处理
  4. java string rt_如何使jvm加载我的java.lang.String而不是rt.jar中的那个
  5. 使用sar进行性能分析
  6. 音乐编辑 java_求助 关于java编辑音乐
  7. 【hiho】127 后缀自动机一·基本概念 【后缀自动机】
  8. SQLPlus获取oracle表操作SQL
  9. 烟花散尽漫说无(參考资料)
  10. html 滑动返回顶部,返回页面顶部的几种方式总结
  11. Tomcat下载安装以及配置(详细教程)
  12. html旅游网站设计与实现——绿色古典旅游景区 HTML+CSS+JavaScript
  13. C语言全局变量,局部变量,静态局部变量的区分
  14. Power Designer 概念数据模型导出 逻辑数据模型和物理数据模型 生成数据库脚本
  15. 好看简约加速器官网源码
  16. BitTorrent 原理简介
  17. PSENet(Shape Robust Text Detection with Progressive Scale Expansion Network)论文详解
  18. 【数据分析与可视化】Pandas-Dataframe-IO操作
  19. 基于车辆运动学模型的LQR横向控制算法
  20. 【JavaEE基础与高级 第42章】C3P0连接数据库操作顺序

热门文章

  1. 度量两个概率分布差异性/距离的指标总结_KL 散度(相对熵)交叉熵 JS散度 Wasserstein-1距离 Earth-Mover (EM)distance
  2. 输入一个链表,按链表值从尾到头的顺序返回一个ArrayList
  3. 在Windows系统上安装PHP工作环境
  4. 设计模式-适配器模式(Adapter)
  5. 如何在settings里的休眠模式里添加永不休眠
  6. 二分图最大匹配(匈牙利算法) URAL 1721 Two Sides of the Same Coin
  7. [bbk4965] 第102集 -第13章 - 表空间管理 00
  8. Oracle中常用的to_Char用法详解(有FMT的详细列表)
  9. 【错误】函数调用导致堆栈不对称。原因可能是托管的 PInvoke 签名与非托管的目标签名不匹配。
  10. 【算法学习】【图像增强】【Retinex】White Patch Retinex 程序解读