使用正则表达式可以很好解决
import re s = ‘Hello!This?Is!What?I!Want‘ ss = re.split(‘[!?]‘, s) ss = [‘Hello‘, ‘This‘, ‘Is‘, ‘What‘, ‘I‘, ‘Want‘]
时间: 2024-11-09 02:51:14
使用正则表达式可以很好解决
import re s = ‘Hello!This?Is!What?I!Want‘ ss = re.split(‘[!?]‘, s) ss = [‘Hello‘, ‘This‘, ‘Is‘, ‘What‘, ‘I‘, ‘Want‘]