st.isalnum()
所有字符都是数字或者字母
st.isalpha()
所有字符都是字母
st.isdigit()
所有字符都是数字;
st.islower()
所有字符都是小写;
st.isupper()
所有字符都是大写;
st.istitle()
所有单词都是首字母大写;
st.isspace()
所有字符都是空白字符\t、\n、\r ;
#unicode
>>> tr = "1"
>>> tr.isdigit()
True
>>> tr.isdecimal()
True
>>> tr.isnumeric()
True
#byte
>>> num = b"1"
>>> num.isdigit()
True
>>> num.isdecimal()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'bytes' object has no attribute 'isdecimal'
>>> num.isnumeric()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'bytes' object has no attribute 'isnumeric'
#汉字
>>> num = "一"
>>> num.isdigit()
False
>>> num.isdecimal()
False
>>> num.isnumeric()
True
————————————————
版权声明:本文为CSDN博主「轩轩n」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_44897792/article/details/100883033