已采纳回答 / lymo
没看出来有多精简,而且100遍历到1000得耗费多长时间~还不如:<...code...>不过感觉还是以字符形式组合快,虽然占资源较多:(不知道对不对,凑合看吧)<...code...>
2015-03-25
score = 55
if score>=60:
print '还行吧,再接再厉!'
else:
print '我去,又挂了!'
if score>=60:
print '还行吧,再接再厉!'
else:
print '我去,又挂了!'
2015-03-25
最新回答 / Fantasy轩
这个其实是html的问题,html的tr标签表示行,td标签表示单元格,这里不加\n也完全没有问题,效果是一样的,只是打印出来时候增加点可读性,同样你要每行都加'\n'也是可以的,解析html的时候都会被自动忽略掉
2015-03-25
已采纳回答 / 廖雪峰
%s是万能替换法,如果要精确控制int用%d>>> '%d' % 12'12'>>> '%4d' % 12' 12'>>> '%04d' % 12'0012'
2015-03-24
sum = 0
x = 0
while True:
x = x + 1
if x > 100:
break
elif x % 2 ==0:
continue
sum = sum + x
print sum
x = 0
while True:
x = x + 1
if x > 100:
break
elif x % 2 ==0:
continue
sum = sum + x
print sum
2015-03-24
s = set([('Adam', 95), ('Lisa', 85), ('Bart', 59)])
for x in s:
print x[0] + ':' + str(x[1])
#or# print " %s: %s" %x
for x in s:
print x[0] + ':' + str(x[1])
#or# print " %s: %s" %x
2015-03-24
months = set(['jan','Feb'])
x1 = 'Feb'
x2 = 'Sun'
if x1 in months:
print 'x1: ok'
else:
print 'x1: error'
if x2 in months:
print 'x2: ok'
else:
print 'x2: error'
x1 = 'Feb'
x2 = 'Sun'
if x1 in months:
print 'x1: ok'
else:
print 'x1: error'
if x2 in months:
print 'x2: ok'
else:
print 'x2: error'
2015-03-24