map函数

  • 将 列表里的数字平方
    num_1 = [2,5,68,4,9]
    num_0 = []
    for i in num_1 :
        num_0 .append(i**2)
    print(num_0 )
    def map_test(arry):
        num_0 = []
        for i in num_1:
            num_0.append(i ** 2)
        return num_0
    print(map_test(num_1 ))
    msg = "shuai"
    print(list(map(lambda x:x.upper(),msg) ))
原文地址:https://www.cnblogs.com/alex-anan/p/8438996.html