如何在python中通过字符串.发音以及string.whitespace同时提姆

2024-06-26 01:39:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我写这个代码:

import re
import string

new_string = re.split(string.pronunciation|string.whitespace, string)

但它不起作用


Tags: 代码importrenewstringsplitwhitespacepronunciation
1条回答
网友
1楼 · 发布于 2024-06-26 01:39:15

试试new_string = re.split('[%s]' % (string.punctuation + string.whitespace), 'Some. String')

正如您在错误消息中看到的那样,str不支持运算符|,您可能将punctuation误键入为pronunciation。你知道吗

相关问题 更多 >