def is_valid_str(s): """判断字符串是否有效,即非空且非空格。""" return isinstance(s, str) and len(s.strip()) > 0 def is_empty_str(s): """判断字符串是否为空,即空或仅包含空格。""" return isinstance(s, str) and len(s.strip()) == 0