这是代码示例:
from django.shortcuts import render_to_response
import MySQLdb
def book_list(request):
db = MySQLdb.connect(user='me', db='mydb', passwd='secret', host='localhost')
cursor = db.cursor()
cursor.execute('SELECT name FROM books ORDER BY name')
names = [row[0] for row in cursor.fetchall()]
db.close()
return render_to_response('book_list.html', {'names': names})
该行特别是:
names = [row[0] for row in cursor.fetchall()]
我只是想了解,这行特别如何,我知道这是一种简写方式,但是有人可以提供长版本的外观吗?