python 字符串分割与拼接

2022-01-10 08:44:27 浏览数 (3)

line = 'asdf fjdk; afed, fjek,asdf, foo' import re re.split(r'[;,s]s*', line) ['asdf', 'fjdk', 'afed', 'fjek', 'asdf', 'foo']

''.join(v d for v,d in zip(values, delimiters)) 'asdf fjdk;afed,fjek,asdf,foo'

1 人点赞