把循环变量i放到函数参数的默认值如何?
def count(): fs = [] for i in range(1, 4): def f(x=i): a = x*x return a fs.append(f) return fs f1, f2, f3 = count() print f1(), f2(), f3()
def count(): fs = [] for i in range(1, 4): def f(x=i): a = x*x return a fs.append(f) return fs f1, f2, f3 = count() print f1(), f2(), f3()
2015-05-04
举报