Python re模块split方法: 多个字符分割字符串(普通split方法只能用一个字符分割字符串)
import re
a = "Hello world!How are you?My friend.Tom"
print(re.split(" |!|\?|\.", a))
输出:
[‘Hello’, ‘world’, ‘How’, ‘are’, ‘you’, ‘My’, ‘friend’, ‘Tom’]
Python re模块split方法: 多个字符分割字符串(普通split方法只能用一个字符分割字符串)
import re
a = "Hello world!How are you?My friend.Tom"
print(re.split(" |!|\?|\.", a))
输出:
[‘Hello’, ‘world’, ‘How’, ‘are’, ‘you’, ‘My’, ‘friend’, ‘Tom’]