months = set(['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'
2017-01-07
已采纳回答 / 话歪之地
因为L = ['Adam', 'Lisa', 'Bart'],所以L.pop()是'Bart',此时L=['Adam', 'Lisa']所以执行完第一行L.insert(0,L.pop())之后L=['Bart','Adam', 'Lisa']当L=['Bart','Adam', 'Lisa'],L.pop(1)是'Adam',此时L=['Bart','Lisa'],此时执行完第二行L.append(L.pop(1))之后L=['Bart','Lisa','Adam']这样就实现了第一个和第三个元素交换的...
2017-01-06
x1 = 1
d = 3
n = 100
x100 = x1+(n-1)*d
s = (x1+x100)*n/2
print s
d = 3
n = 100
x100 = x1+(n-1)*d
s = (x1+x100)*n/2
print s
2017-01-06
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()]
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()]
2017-01-06
x1 = 1
d = 3
n = 100
x100 = n*d-2
s = (x1+x100)*(n/2)
print s
d = 3
n = 100
x100 = n*d-2
s = (x1+x100)*(n/2)
print s
2017-01-06