Python判断字符串组成的方法

mystr = 'hello world and gzy and java and python'

print(mystr.isalpha())  # 是否是纯字母构成
print(mystr.isalnum())  # 是否是字母和数字的组合
print(mystr.isdigit())  # 是否是纯数字构成
print(mystr.isspace())  # 是否是空白构成

posted @ 2021-03-08 15:35  code-G  阅读(256)  评论(0编辑  收藏  举报