gpt4 book ai didi

python - 在 Python 中获取标点符号的字符串常量

转载 作者:行者123 更新时间:2023-12-05 00:41:53 27 4
gpt4 key购买 nike

如何访问 Python 的字符串常量?

我需要获取 Python 文档所说的标点符号列表 string.punctuation

这行不通

''.punctuation
''.get_value("punctuation")

我正在尝试的可能吗?

最佳答案

string.punctuation 中的

string 不是指类型 str,而是指 string module :

In [32]: import string

In [33]: string.punctuation
Out[33]: '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'

关于python - 在 Python 中获取标点符号的字符串常量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15584412/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com