Discuss / Python / 利用参数默认值,其实还可以这么写,分享一下

利用参数默认值,其实还可以这么写,分享一下

Topic source

颜名48715

#1 Created at ... [Delete] [Delete and Lock User]

def count(): fs = [] for i in range(1, 4): def f(): return lambda x=i:x**2 fs.append(f()) return fs

f1, f2, f3 = count() print(f1(),f2(),f3())


  • 1

Reply