2024-06-26 01:39:15 发布
网友
我写这个代码:
import re import string new_string = re.split(string.pronunciation|string.whitespace, string)
但它不起作用
试试new_string = re.split('[%s]' % (string.punctuation + string.whitespace), 'Some. String')
new_string = re.split('[%s]' % (string.punctuation + string.whitespace), 'Some. String')
正如您在错误消息中看到的那样,str不支持运算符|,您可能将punctuation误键入为pronunciation。你知道吗
str
|
punctuation
pronunciation
试试
new_string = re.split('[%s]' % (string.punctuation + string.whitespace), 'Some. String')
正如您在错误消息中看到的那样,
str
不支持运算符|
,您可能将punctuation
误键入为pronunciation
。你知道吗相关问题 更多 >
编程相关推荐