即使 for 循环正常工作,我也无法让我的列表理解语句工作。我用它来创建一个带有reportlab的表类的表
# 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)