1031题 -一行流解决(Python代码) 摘要:将用replace函数将字符串中的所有空格去掉 ``` print(input().replace(" ","")[::-1]) ``` 上面的代码是下面的简写: ``` list =…… 题解列表 2019年11月24日 0 点赞 0 评论 2123 浏览 评分:8.0
[编程入门]自定义函数之字符串反转-题解(Python代码) python ```pythonstr=input()#输入foriinrange(len(str)-1,-1,-1):#列表最后一位下标的元素往前循环,#步长为-1,直到数组下标为0的元素ifstr[i]=='':#如果字符是空格就跳过continueprint(str[i],end="")#输出``` 题解列表 2019年11月21日 0 点赞 0 评论 1601 浏览 评分:6.0