print s
显示如下:
set([('Lisa', 85), ('Adam', 95), ('Bart', 59)])
print x
显示如下:
('Lisa', 85)
('Adam', 95)
('Bart', 59)
以下三个命令输出结果相同:
print x[0]+':', x[1]
print x[0]+':'+str(x[1])
print "%s: %s" %x
显示如下:
Lisa: 85
Adam: 95
Bart: 59
显示如下:
set([('Lisa', 85), ('Adam', 95), ('Bart', 59)])
print x
显示如下:
('Lisa', 85)
('Adam', 95)
('Bart', 59)
以下三个命令输出结果相同:
print x[0]+':', x[1]
print x[0]+':'+str(x[1])
print "%s: %s" %x
显示如下:
Lisa: 85
Adam: 95
Bart: 59
2015-05-10
weekdays = set(['MON','TUE','WED','THU','FRI','SAT','SUN'])
x = 'MON'
if x in weekdays:
print 'input error'
else:
print 'input ok'
这里的逻辑有反了吧。两print应该对调一下就对了哦……。
x = 'MON'
if x in weekdays:
print 'input error'
else:
print 'input ok'
这里的逻辑有反了吧。两print应该对调一下就对了哦……。
2015-05-10
print [ int(bytes(i)+bytes(j)+bytes(k)) for i in range(1,10) for j in range(0,10) for k in range(0,10) if i == k ]
2015-05-10
def generate_tr(name, score):
sty = ('style="color:red"' if score<60 else '')
return '<tr><td>%s</td><td %s>%s</td></tr>' % (name, sty, score)
sty = ('style="color:red"' if score<60 else '')
return '<tr><td>%s</td><td %s>%s</td></tr>' % (name, sty, score)
2015-05-10
for k, v in d.items():
sum = sum + v
print "%s:%s"%(k,v)
print 'average', ':', sum/len(d)
sum = sum + v
print "%s:%s"%(k,v)
print 'average', ':', sum/len(d)
2015-05-10
.....报59错,那就送多个59给他呗
L = [95.5,85,59,59]
print L[0]
print L[1]
print L[2]
print L[3]
L = [95.5,85,59,59]
print L[0]
print L[1]
print L[2]
print L[3]
2015-05-10