def toUppers(L):
a=[]
for x in L:
if isinstance(x, str):
a.append(x.upper())
print a
toUppers(['Hello', 'world', 101])
a=[]
for x in L:
if isinstance(x, str):
a.append(x.upper())
print a
toUppers(['Hello', 'world', 101])
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for key,value in d.items():
print key+':'+str(value)
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for key,value in d.items():
print key+':'+str(value)
2016-11-01
就像低价买进高价卖出就能赚钱一样简单,可还是有很多人做生意赔钱,有时候看评论就会觉得得意:聪明人还是少,自以为聪明的傻瓜还是占大多数,生活中到处都是这样的例子。然而当我打下这段话,我也变成了后者。
2016-11-01
print "'"+r'''\"To be, or not to be\": that is the question.\nWhether it\'s nobler in the mind to suffer.'''+"'"
2016-11-01
def greet(x):
if x:
print 'hello,',x,'.'
else:
print 'hello,world.'
greet('')
greet('Bart')
if x:
print 'hello,',x,'.'
else:
print 'hello,world.'
greet('')
greet('Bart')
2016-11-01
def move(n, a, b, c):
if n==1:
print a,'-->',c
else:
move(n-1,a,c,b)
move(1,a,b,c)
move(n-1,b,a,c)
move(4, 'A', 'B', 'C')
if n==1:
print a,'-->',c
else:
move(n-1,a,c,b)
move(1,a,b,c)
move(n-1,b,a,c)
move(4, 'A', 'B', 'C')
2016-11-01