📌  相关文章
📜  将一个字符串分成 N 个相等的部分. - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:03.802000             🧑  作者: Mango

代码示例1
your_string = [i for i in range(20)]
n= 5
parts = [your_string[i:i+n] for i in range(0, len(your_string), n)]
print(parts)
#[[0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19],]