标签:color code 字符 pre 拆分 end div extend 分隔符
map实现
def mySplit(s, ds): res = [s] for d in ds: t = [] list(map(lambda x: t.extend(x.split(d)), res)) res = t return [x for x in res if x] s = ‘ab;cd|efg|hi,jkl|mn\topq;rst,uvw\txyz‘ ds = ‘;,|\t‘ print(mySplit(s, ds))
re.split实现
import re s = ‘ab;cd|efg|hi,jkl|mn\topq;rst,uvw\txyz‘ ds = ‘;,|\t‘ print(re.split(r‘[,;\t|]+‘, s))
标签:color code 字符 pre 拆分 end div extend 分隔符
原文地址:https://www.cnblogs.com/ray-mmss/p/10464590.html