Python isalpha()检查字符串是否仅由字母字符组成。
str.isalpha()
如果字符串中的所有字符都是字母,并且至少有一个字符,则此方法返回true,否则返回false。
以下示例显示isalpha()方法的用法。
链接:https://www.learnfk.comhttps://www.learnfk.com/python/string-isalpha.html
来源:LearnFk无涯教程网
#!/usr/bin/python str="this"; # 此字符串中没有空格和数字 print str.isalpha() str="this is string example....wow!!!"; print str.isalpha()
当无涯教程运行上面的程序时,它产生以下输出-
True False
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)