isalpha()方法:判断字符串是否只由字母组成,如果字符串中所有字符都是字母则返回True,否则返回False。
str1 = "python"
print(str1.isalpha()) #True
# 中文的汉字会被isalpha判定为True
str2 = "我是一只大花猫"
print(str2.isalpha()) # True
# 如果想区分中文和英文可以使用unicode,中文的范围为:['/u4e00','/u9fa5']
print(str2.encode("utf-8").isalpha()) # False
str3 = "cat花猫"
print(str3.isalpha()) # True
print(str3.encode("utf-8").isalpha()) # False