leetcode中Reverse Words in a String 问题(简单)

##问题描述

Given an input string, reverse the string word by word.

For example,
Given s = “the sky is blue”,
return “blue is sky the”.

click to show clarification.

简单介绍一下,即字符串的反转

##python代码
class Solution:

# @param s, a string
# @return a string
def reverseWords(self, s):
    items = s.strip().split(" ")
    items = items[::-1]
    str = ""
    for i in items:
        if(i != ""):
            str = str + i + " "
    str = str[0:len(str)-1]
    return str

##问题分析
>

本题主要需要注意空格的分割