0
点赞
收藏
分享

微信扫一扫

Python的字符串内容检查方法


Python的字符串内容检查方法

总体参考文档:​​https://docs.python.org/zh-cn/3/library/stdtypes.html​​

isalnum()

检测字符串是否由字母和数字组成

参考资料:​​https://www.runoob.com/python3/python3-string-isalnum.html​​

isalpha()

检测字符串是否只由字母组成

参考资料:​​https://www.runoob.com/python3/python3-string-isalpha.html​​

isascii()

检测字符串是否均有ASCII编码的字符组成

参考资料:​​https://docs.python.org/zh-cn/3/library/stdtypes.html?highlight=isascii#str.isascii​​

isdecimal()

检查字符串是否只包含十进制字符(针对Unicode对象)

参考资料:​​https://www.runoob.com/python/att-string-isdecimal.html​​

isdigit()

检测字符串是否只由数字组成

参考资料:​​https://www.runoob.com/python3/python3-string-isdigit.html​​

isidentifier()

判断字符串是否是有效的 Python 标识符

islower()

检测字符串是否由小写字母组成

参考资料:​​https://www.runoob.com/python3/python3-string-islower.html​​

isnumeric()

检测字符串是否只由数字组成(针对Unicode对象)

参考资料:​​https://www.runoob.com/python3/python3-string-isnumeric.html​​

isprintable()

检查字符串中的字符是否都是可打印字符

isspace()

检测字符串是否只由空格组成

参考资料:​​https://www.runoob.com/python3/python3-string-isspace.html​​

istitle()

检测字符串中所有的单词拼写首字母是否为大写,且其他字母为小写

参考资料:​​https://www.runoob.com/python3/python3-string-istitle.html​​

isupper()

检测字符串中所有的字母是否都为大写

参考资料:​​https://www.runoob.com/python3/python3-string-isupper.html​​



举报

相关推荐

0 条评论