有没有办法在不知道字符串长度的情况下4*x,将一个x字符长的字符串切成4个字符串,每个字符长?
4*x
x
例如:
>>>x = "qwertyui" >>>split(x, one, two, three, four) >>>two 'er'
>>> x = "qwertyui" >>> chunks, chunk_size = len(x), len(x)/4 >>> [ x[i:i+chunk_size] for i in range(0, chunks, chunk_size) ] ['qw', 'er', 'ty', 'ui']