classSolution:defreverseLeftWords(self, s:str, n:int)->str:
newstr=[]for i inrange(n,len(s)):
newstr.append(s[i])for i inrange(0,n):
newstr.append(s[i])return''.join(newstr)
方法三:遍历字符串
classSolution:defreverseLeftWords(self, s:str, n:int)->str:
newstr=''for i inrange(n,len(s)):
newstr+=s[i]for i inrange(0,n):
newstr+=s[i]return newstr