#####序言: 总结Python在字符串方面如何高效判断中文、英文、数字或者其他字符的经验, 不断更新~
###判断中文
st = "我爱中国abc" for s in st: if s >= u'\u4e00' and s<=u'\u9fa5': print("%s 是中文" %s)
效果图:
###判断英文
st = "我爱中国I love China" for s in st: if (s >= u'\u0041' and s <= u'\u005a') or (s >= u'\u0061' and s <= u'\u007a'): print("%s 是英文" %s)
效果图:
###判断数字
st = "我爱中国I love China 520" for s in st: if s.isdigit(): print("%s 是数字" %s)
效果图:
###判断空格
st = "我爱中国I love China 520" for s in st: if s.isspace(): print("%s 是空格" %s)
效果图:
###判断特殊字符,可基于以上情况的else