python3将一个文本按照一定字符数切分

def cuttingText(text,num):
    textlist = []          ## 空列表
    while(text!=''):
        textlist.append(text[0:num])
        text=text[num:]
    return textlist

关键是中间不能落下字符

猜你喜欢

转载自www.cnblogs.com/yanghao2008/p/10668248.html