标签:span 列表 class 模拟 拼接 字符串 fun 通过 code
result = s[::-1]
li =[‘b‘, ‘c‘, ‘f‘, 4, 5, 6] a = list(reversed(li)) print (a) 输出: [6, 5, 4, ‘f‘, ‘c‘, ‘b‘]
result = reduce(lambda x,y:y+x,s) #不认识,先记着
def func(s): #此处使用递归,不断把第一个字符,通过拼接的方式加到分片字符串后面,而分片字符串是将函数实参的第一个字符丢弃 if len(s) <1: return s return func(s[1:])+s[0] result = func(s)
def func(s): l = list(s) #模拟全部入栈 result = "" while len(l)>0: result += l.pop() #模拟出栈 return result result = func(s)
def func(s): result = "" max_index = len(s)-1 for index,value in enumerate(s): result += s[max_index-index] return result result = func(s)
标签:span 列表 class 模拟 拼接 字符串 fun 通过 code
原文地址:https://www.cnblogs.com/mailong/p/12003258.html