Python 有str.isalnum()
, str.isdigit()
, str.isupper()
, str.islower()
, str.isalpha()
,但是它是否有任何内置的字符串验证检查特殊字符或标点符号? (即!@#$%^&*().,;'": 等)
标准string
模块提供string.punctuation https://docs.python.org/3/library/string.html#string.punctuation,其中包含标点符号。您可以通过以下方式测试成员资格:
def ispunct(ch):
return ch in string.punctuation
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)