解题思路
主要采用了s.split()和python的切片技术
代码
class Solution(object): def reverseWords(self, s): """ :type s: str :rtype: str """ b = "" s = s.split() for i,num in enumerate(s): if i == 0: b = num[::-1] else: b += " " + num[::-1] return b
主要采用了s.split()和python的切片技术
class Solution(object): def reverseWords(self, s): """ :type s: str :rtype: str """ b = "" s = s.split() for i,num in enumerate(s): if i == 0: b = num[::-1] else: b += " " + num[::-1] return b