557. 反转字符串中的单词 III
class Solution:
def reverseWords(self, s):
"""
:type s: str
:rtype: str
"""
words = s.split(' ')
for i in range(len(words)):
words[i] = words[i][:: -1]
return ' '.join(words)
1.主要思路识别空格,以空格分开单词,然后变换为344反转字符串