def split_by_separator(string='', separators=','): rst = [string] for sep in separators: tmp = [] for r in rst: tmp.extend(map(lambda x: x.strip(), r.split(sep))) rst = tmp list_tmp = [] [list_tmp.append(data) for data in rst if data != ''] return reduce(lambda x, y: (y in x) and x or (x + [y]), ([[], ] + list_tmp) ) print split_by_separator('la,la,1,2,1+as%*ba', ',+*%')
Python字符串去重,去符号!经典