python中split()进行多分割

python中的split方法只能通过指定的某一个字符分割字符串,因此要实现实现多符号分割的话,就要调用re模块中的split()函数
示例:

>>> import re
>>> words = 'a b c.d?e!f'
>>> re.split(' |!|\?|\.', words)
['a', 'b', 'c', 'd', 'e', 'f']
posted @ 2019-04-26 20:50  樱花色的梦  阅读(12495)  评论(0编辑  收藏  举报