在使用以下代码迭代下列列表时,我会得到一个值错误:
for (row,num) in (cur.fetchall(),range(1,cur.rowcount+1)):清单:
(((2L, 0L, 'You must install a MySQL driver before doing anything. UNlike PHP, only the SQLLite driver is installed by'), (3L, 0L, "default with Python. The most used package to do so is MySQLdb but it's hard to install it using"), (4L, 0L, 'easy_install'), (24L, 0L, ' eine Nachricht '), (25L, 0L, ' Das ging ja schnell '), (27L, 0L, ' Noch ein dicker Hund! ')), [1, 2, 3, 4, 5, 6])第一个列表是一个包含元组本身的列表,第二个列表是一个数字范围。
你能解释一下为什么这不管用吗?
发布于 2014-12-02 09:24:01
Zip!
for (row,num) in zip(cur.fetchall(),range(1,cur.rowcount+1)):https://stackoverflow.com/questions/27245759
复制相似问题