【发布时间】:2018-09-27 21:05:45
【问题描述】:
我尝试了多个来自 mysql 的更新数据。这是我的代码:
que = "select id_pl from datapl
db = MySQLdb.connect("localhost", "root", "", "tuongdata")
cur = db.cursor()
cur.execute(que)
pl = cur.fetchall()
cur.close()
pl = [ i[0] for i in pl ]
di = './newsdata/'
for i in pl:
lin = di + i + '/'
numb = len([name for name in os.listdir(str(lin)) if os.path.isfile(os.path.join(lin, name))])
qq = "update datapl set num = " + str(numb) + " where id_pl = " + str(i)
cur = db.cursor()
cur.execute(qq)
cur.close()
#print qq
db.close()
但它不起作用,我不知道为什么:(
【问题讨论】:
-
您需要在第一行末尾加上一个双引号
"。
标签: python python-2.7 mysql-python