151. 翻转字符串里的单词




class Solution(object):
    def reverseWords(self, s):
        """
        :type s: str
        :rtype: str
        """
        words = s.split()
        return ' '.join(words[::-1])


if __name__ == '__main__':
    s = Solution()
    print(s.reverseWords("  hello world!  "))
原文地址:https://www.cnblogs.com/panweiwei/p/14024778.html