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!  "))
posted @ 2020-11-23 15:35  人间烟火地三鲜  阅读(75)  评论(0编辑  收藏  举报