# 如果是带有判断的写在后
new_list = [i for i in files if i == 1]
# 不带判断写在前
new_list = [f.replace('1','') for f in files]
# 下面写if else的 用字典
data = [1, 2, 3, 4, 5]
result = {x: 'even' if x % 2 == 0 else 'odd' for x in data}
print(result) # 输出: {1: 'odd', 2: 'even', 3: 'odd', 4: 'even', 5: 'odd'}
关于匿名函数
f=lambda a,b,c,d:a*b*c*d
print(f(1,2,3,4))
#相当于下面这个函数
def test01(a,b,c,d):
return a*b*c*d
print(test01(1,2,3,4))
g=[lambda a:a*2,lambda b:b*3]
#调用
print(g[0](5))
print(g[1](6))