面试题58:题目2左旋转字符串

输入:“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))

  

上一篇:02activiti - 工作流介绍


下一篇:python之字符串反转