标签:return div rgba spl split += 每日 bsp span
错解
class Solution: def reverseWords(self, s: str) -> str: a=[] s=s.split() for i in s: if i!=‘‘: left=0 right=len(i)-1 while left <right: i[left],i[right]=i[right],i[left]#字符串不可以这么改,因为字符串不可变 left+=1 right-=1 a.append(i) return s
正解:
class Solution: def reverseWords(self, s: str) -> str: return ‘ ‘.join(i[::-1] for i in s.split())
标签:return div rgba spl split += 每日 bsp span
原文地址:https://www.cnblogs.com/liuxiangyan/p/14529278.html