修改一下生成表格的函数就行了
def generate_tr(name, score):
if score>60:
return '<tr><td>%s</td><td>%s</td></tr>' % (name, score)
else:
return '<tr><td>%s</td><td style="color:red">%s</td></tr>' % (name, score)
tds = [generate_tr(name,score) for name, score in d.iteritems()]
def generate_tr(name, score):
if score>60:
return '<tr><td>%s</td><td>%s</td></tr>' % (name, score)
else:
return '<tr><td>%s</td><td style="color:red">%s</td></tr>' % (name, score)
tds = [generate_tr(name,score) for name, score in d.iteritems()]
2016-04-13
t = ('a', 'b', ('A', 'B'))
print t
print t
2016-04-13
L = ['Adam', 'Lisa', 'Bart']
L[0]="Bart";
L[2]="Adam";
print L
L[0]="Bart";
L[2]="Adam";
print L
2016-04-13
每次只能挪一个,大盘子只能在小盘子下面,这两个条件如果不知道的话,这题没法做了
def move(n,a,b,c):
if n == 1:
print a, '-->', c
return
else:
move(n-1,a,c,b)
print a, '-->', c
move(n-1,b,a,c)
move(4,'A','B','C')
def move(n,a,b,c):
if n == 1:
print a, '-->', c
return
else:
move(n-1,a,c,b)
print a, '-->', c
move(n-1,b,a,c)
move(4,'A','B','C')
2016-04-13
for x in ['1','2','3','4','5','6','7','8','9']:
for y in ['2','3','4','5','6','7','8','9']:
if x < y:
print x+y
for y in ['2','3','4','5','6','7','8','9']:
if x < y:
print x+y
2016-04-13
@Mr_listening 你的这一行print qua(3,3,4)导致b*b-4*a*c为负数,sqrt()不能对负数开方,所以会导致错误
2016-04-13
for x in [1,2,3,4,5,6,7,8,9]:
for y in [0,1,2,3,4,5,6,7,8,9]:
if x < y:
print((x*10)+y)
for y in [0,1,2,3,4,5,6,7,8,9]:
if x < y:
print((x*10)+y)
2016-04-13
# -*- coding: utf-8 -*-
print r'''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。'''
print r'''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。'''
2016-04-13
已采纳回答 / 0twt0
sum 是个累加的过程,x在while中循环 ,每次循环都在上一次的基础上乘2,即1.2.4.8...,直到n一直加到20,退出循环,sum就是把x的每个循环数据加起来,最后输出
2016-04-13