1 # 旋转字符串 给定一个字符串 (以字符数组的形式)和有个偏移量,根据偏移量原地从左向右旋转字符串 2 # 输入 str = 'abcdefg' offset = 3 输出 efgabcd 输入 str= 'abcdefg' offset = 0 输出 abcdefg 3 # 输入 stt = 'abcdefg' offset = 1 输出 gabcdef 4 class Solution: 5 def reverse_str(self, string, offset): 6 s = string[-offset:] + string[:-offset] 7 return s 8 9 10 c1 = Solution() 11 print(c1.reverse_str('abcdefg', 3))