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) ))

     

posted on 2018-02-10 15:57  python_an  阅读(106)  评论(0编辑  收藏  举报

导航