def split(self, *args):
# to verify arguments
''.split(*args)
sep, maxsplit = (list(args) + [None, None])[:2]
if maxsplit is None:
maxsplit = -1
keep_empty = True
keep_sep = False
line, colored_chars = self._separate_str_and_colors()
i = 0
if sep is None:
sep = '\s+'
keep_empty = False
# to skip whitespaces at the beginning
# ' a b'.split() -> ['a', 'b']
n = len(line)
while i < n and line[i] in string.whitespace:
i += 1
return self._split(line[i:], colored_chars[i:], sep, maxsplit, keep_sep, keep_empty)
评论列表
文章目录