妹的 我就说怎么搞得越来越难了 感觉就不是在一个层次上 这样啊 我就去另外找资源学python去了
2016-06-05
def format_name(s):
return s.title()
print map(format_name, ['adam', 'LISA', 'barT'])
return s.title()
print map(format_name, ['adam', 'LISA', 'barT'])
2016-06-04
a, b = b, a + b其实就是多个变量的赋值运算,先算=右边,再赋值给左边变量:
0)a=0,b=1
1)a=b=1,b=a+b=1
2)a=b=1,b=a+b=2
3)a=b=2,b=a+b=3
4)a=b=3,b=a+b=5
5)a=b=5,b=a+b=8
6)a=b=8,b=a+b=13
7)a=b=13,b=a+b=21
8)a=b=21,b=a+b=34
9)a=b=34,b=a+b=55
0)a=0,b=1
1)a=b=1,b=a+b=1
2)a=b=1,b=a+b=2
3)a=b=2,b=a+b=3
4)a=b=3,b=a+b=5
5)a=b=5,b=a+b=8
6)a=b=8,b=a+b=13
7)a=b=13,b=a+b=21
8)a=b=21,b=a+b=34
9)a=b=34,b=a+b=55
2016-06-04
最新回答 / 慕勒9756884
不然你试试在lambda前加个key=,我在http://stackoverflow.com/questions/23082372/sorting-a-list-with-lambda-with-a-variable-number-of-arguments看到个感觉和你很像的问题,刚学,共勉
2016-06-04
和js的闭包一个意思
def count():
fs = []
for i in range(1, 4):
def ff(i):
def g():
return i*i
return g
fs.append(ff(i))
return fs
f1, f2, f3 = count()
print f1(), f2(), f3()
def count():
fs = []
for i in range(1, 4):
def ff(i):
def g():
return i*i
return g
fs.append(ff(i))
return fs
f1, f2, f3 = count()
print f1(), f2(), f3()
2016-06-04
import math
def is_sqr(x):
return math.sqrt(x)%1==0
print filter(is_sqr, range(1, 101))
def is_sqr(x):
return math.sqrt(x)%1==0
print filter(is_sqr, range(1, 101))
2016-06-03
最新回答 / bighills
def cmp_ignore_case(s1, s2): u1=s1.lower() u2=s2.lower() if u1<u2: return -1 if u1>u2: return 1 return 0print sorted(['bob', 'about', 'Zoo', 'Credit'],cmp_ignore_case)
2016-06-03