Write a function that takes a string as input and returns the string reversed.
Example:
Given s = "hello", return "olleh".
思路:
使用Python解决这个问题就极为方便了:s[::-1]
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
class Solution(object):
def reverseString(self, s):
"""
:type s: str
:rtype: str
"""
return s[::-1]
if __name__ == '__main__':
sol = Solution()
s = "hello"
print sol.reverseString(s)
网友评论