最赞回答 / pig2guang
这串代码应该print不出来东西:for x in d 这里每次循环取出的x就是d里面每个item的key(95,85,59),d.get(x)就是用来得到该key对应的value(例如这里d.get(95)='Adam'),我们可以看到d 里面并没有哪个value是95(注意别把key 和value弄混了),所以输不出东西。
2016-09-19
不会写1-12月份的,看这里
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'
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'
2016-09-19