-
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)
else:
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>' -
def toUpper(L): #将字符变为大写字符
return [x.upper() for x in L if isinstance(x,str) ]
print toUppers('Hello','World',232) -
print [100n1+10n2+n3 for n1 in range(1,10) for n2 in range(10) for n3 in range(10) if n1==n3] #输出对称的三位数
点击查看更多内容
1人点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦