2
即使for循環正常工作,我也無法讓列表理解語句正常工作。我用它來創建一個表ReportLab的的表類正常for循環工作正常時,列表理解不起作用
# Service Table
heading = [('Service', 'Price', 'Note')]
# This doesn't work as in there is no row in the output
heading.append([(s['name'],s['price'],s['note']) for s in services])
table = Table(heading)
# This displays the table correctly
for s in services:
heading.append((s['name'], s['price'], s['note']))
table = Table(heading)
謝謝。這是現貨。 – 2013-03-01 09:14:18