小编lei*_*rem的帖子

使用split()在不同的标点符号上划分字符串

我正在尝试将字符串分成单词,删除空格和标点符号.

我尝试使用该split()方法,立即传递所有标点符号,但我的结果不正确:

>>> test='hello,how are you?I am fine,thank you. And you?'
>>> test.split(' ,.?')
['hello,how are you?I am fine,thank you. And you?']
Run Code Online (Sandbox Code Playgroud)

我实际上已经知道如何用正则表达式做这个,但我想弄清楚如何使用它split().请不要给我一个正则表达式的解决方案.

python string split

7
推荐指数
5
解决办法
2万
查看次数

标签 统计

python ×1

split ×1

string ×1