from functools import reduce # method one:字符串拼接 def method_one(a_list):     num = "".join(map(str,a_list))     return num # method two:循环 def method_two(a_list):     num = 0     for i in a_list:         num = num*10 + int(i)     return num # method three:Python内建的高阶函数 def method_three(a_list):     num = reduce(lambda x,y: str(x) + str(y), a_list)     return num list = [1, 2, 3, 4, 5, 6, 7, 8, 9] print(method_one(list)) print(method_two(list)) print(method_three(list))
点赞 评论

相关推荐

训猪勇士:别拷打了,你把你学校后面四个字去掉都走不了算法,认清现实
点赞 评论 收藏
分享
2025-12-15 14:25
云南大学 Java
lei22:入职可能会看学信网,最好别伪装,这个简历找实习肯定是够的,肯定会有收 28 届实习生的公司的,多投就行
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务