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>'

  

相关文章:

  • 2021-08-04
  • 2022-12-23
  • 2021-07-29
  • 2022-12-23
  • 2021-05-16
  • 2022-01-02
  • 2021-12-29
  • 2022-12-23
猜你喜欢
  • 2021-10-05
  • 2022-12-23
  • 2021-06-20
  • 2022-12-23
  • 2022-12-23
  • 2022-01-28
  • 2021-09-11
相关资源
相似解决方案