我只想从一开始就切字符串,就像我有一个句子一样:

"All the best wishes"


我想得到

"the best wishes" , "best wishes", "wishes".


任何解决方案,谢谢!

最佳答案

>>> words
['All', 'the', 'best', 'wishes']
>>> [" ".join(words[i:]) for i in range(len(words))]
['All the best wishes', 'the best wishes', 'best wishes', 'wishes']
>>> [" ".join(words[i:]) for i in range(len(words))][1:]
['the best wishes', 'best wishes', 'wishes']

10-06 00:55