You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何实现滚动文本字符循环重排?生成指定移位字符串列表

滚动文本字符循环重排实现

需求:实现滚动文本字符循环重排功能,将输入字符串的字符从索引0到末尾依次进行循环移位,生成指定格式的字符串列表。

Python实现代码

def scrolling_text(string: str) -> list:
    new_list = []
    string = string.upper()
    for i in range(0, len(string)):
        string = string[i:] + string[:i]
        new_list.append(string)

    return new_list


print(scrolling_text('robot'))   # ["ROBOT", "OBOTR", "BOTRO", "OTROB", "TROBO"]

内容的提问来源于stack exchange,提问作者Andrey Petrus

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.28 17:45:16