04 April 2012

python split string by length

def split_len(seq, length):
    return [seq[i:i+length] for i in range(0, len(seq), length)]

ref(http://code.activestate.com/recipes/496784-split-string-into-n-size-pieces/

No comments:

Post a Comment

Terima kasih