#!/usr/bin/env python3 # -*- coding: utf-8 -*- from functools import reduce list=[1,2,3,4,5,6,7,8,9] #字符串拼接 def fn1(list): s='' for i in list: s+=str(i) return s #循环 def fn2(list): sum=0 for i in list: sum=sum*10+i return sum #内建高阶函数 def fn3(list): m=reduce(lambda x,y:10*x+y,list) return m print(fn1(list)) print(fn2(list)) print(fn3(list))
点赞 评论

相关推荐

牛客网
牛客企业服务