输入:“abcdefg”, 2
输出:“cdefgab”
def leftRote(s,k): if not s: return None s = [i for i in s] temp = s[:k] for i in range(k): del s[0] return ''.join(s+temp) if __name__ == "__main__": s = 'abcdefg' k = 2 print(leftRote(s,k))
2023-12-29 13:32:16
输入:“abcdefg”, 2
输出:“cdefgab”
def leftRote(s,k): if not s: return None s = [i for i in s] temp = s[:k] for i in range(k): del s[0] return ''.join(s+temp) if __name__ == "__main__": s = 'abcdefg' k = 2 print(leftRote(s,k))
下一篇:python之字符串反转