stratswith判断字符串开头是什么主要还是lambda函数的使用

res=lambda x:x.startswith('n')#判断传入的字符串是不是以n开头
print(res('name'))
res=lambda x,y,z:x+y+z
print(res(2,3,4))
res=lambda x,y,z:x+y+z
print(res(2,3,4))
def cal(x,y,z): return x+y+z res=cal(2,3,4) print(res)
res=lambda x,y,z:(x+1,y+1,z+1)#lambda需要用元祖()表示不然显示不出来输出
print(res(2,3,4))
def cal(x,y,z):
    return x+1,y+1,z+1#return则不需要元祖表示
res=cal(2,3,4)
print(res)
原文地址:https://www.cnblogs.com/wfl9310/p/8954922.html