print '\n'.join(tds) 为啥报错
Traceback (most recent call last): File "index.py", line 10, in print '\n'.join(tds) TypeError: sequence item 0: expected string, function foundNameScore
Traceback (most recent call last): File "index.py", line 10, in print '\n'.join(tds) TypeError: sequence item 0: expected string, function foundNameScore
2019-09-24
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59 }
def generate_tr(name, score):
if score < 60:
return '<tr><td>%s</td><td style="color:red">%s</td></tr>' % (name, score)
return '<tr><td>%s</td><td>%s</td></tr>' % (name, score)
tds = [generate_tr(name, score) for name, score in d.iteritems()]
print '<table border="1">'
print '<tr><th>Name</th><th>Score</th><tr>'
print '\n'.join(tds)
print '</table>'
你试一下用这个代码随后再理解一下
举报