python中的KeyError报错
from util import str_util #业务逻辑:兼容不同的结构体:resCode转化数据 #检查字典中是否存在键 if 'resCode' not in resultJson if 'resCode' not in resultJson: if 'returnCode' in resultJson: resCode = resultJson["returnCode"] if str_util.is_not_blank(resCode) and resCode == "1": resCode = "000000" if 'status' in resultJson: resCode = resultJson["status"] if resCode == 20000: resCode = "000000" else: resCode = resultJson["resCode"] str_util.py def is_blank(str: str): if str and str.strip(): return False return True def is_not_blank(str: str): return is_blank(str) == False