Python中isalpha() 没考虑中文
自己定义一个函数,函数与isalpha()功能相同,要求考虑中文.
自定义函数判断内容是否全为字母
def myalpha(str1):
if str1 == "":
return False
else:
for x in str1:
if x >= 'a' and x <= 'z' or x >= 'A' and x <= "Z":
pass
else:
return False
else:
return True
print(myalpha("1dss"))
print(myalpha("dss"))
print(myalpha("中午呢dss"))
print(myalpha(""))