码迷,mamicode.com
首页 > 编程语言 > 详细

python 复杂表达式,以及表单的处理

时间:2015-05-18 16:34:27      阅读:96      评论:0      收藏:0      [点我收藏+]

标签:

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

  

python 复杂表达式,以及表单的处理

标签:

原文地址:http://www.cnblogs.com/flycenter/p/4512112.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!