# 反转字符串
# 编写一个函数,其作用是将输入的字符串反转过来。
class Solution(object):
def reverse_string(self, s):
# 方法一
a = list(s) # 将字符串转换乘列表
b = a[::-1] # 倒序输出列表
c = "".join(b) # 将列表拼接起来形成字符串
return c
# 方法二
# return s[::-1] # 字符串直接反转