检查接口的传入的变量是否有空值的统一的处理方法
name = "whw" age = " " gender = "male" def check_no_blank(**kwargs): for key in kwargs: # 不能为空或者不能全是空格字符 if kwargs.get(key) == "" or " " in kwargs.get(key): return {"blank":True,"blank_key":key} return {"blank":False,"blank_key":""} # 找到具体是哪个变量是是不符合要求的 ret = check_no_blank(name=name,age=age,gender=gender) print(ret) # {'blank': True, 'blank_key': 'age'}