2024-10-02 10:25:07 发布
网友
我试着用字符串.标点符号函数,我在python3.5版本中做。以下是我的代码:
import string def check(text): x=set(text.punctuation())
我有以下错误
请帮助您正确使用此函数。我甚至尝试过使用ispunct()函数。在
我试图解决这个问题,如下面的链接所示,但无法解决。在
Best way to strip punctuation from a string in Python
punctuation是string模块的方法,不是字符串对象属性。在
punctuation
string
>>> import string >>> >>> string.punctuation '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'
如果要从文本中获取punctuation,可以使用set中的生成器表达式:
set
punctuation
是string
模块的方法,不是字符串对象属性。在如果要从文本中获取
^{pr2}$punctuation
,可以使用set
中的生成器表达式:相关问题 更多 >
编程相关推荐