可以参考一波:https://stackoverflow.com/questions/16573332/jsondecodeerror-expecting-value-line-1-column-1-char-0
1、json格式不对引起的错误
加上if json_rep.content:
判空操作
json_rep = requests.post(url = monitor_url, headers = monitor_header,json = request)
if json_rep == None: logging.info(room_name + " json_rep == None")return 0
if json_rep.content:zhiyan_data = json_rep.json()if(zhiyan_data['code'] != 0):logging.warning(zhiyan_data['msg'])return 0elif len(zhiyan_data['data']) == 0:logging.warning(zhiyan_data['日志信息拉取无结果'])return 0else:res = zhiyan_data['data']['chart_info'][0]['key_data_list'][3]['current']logging.info(room_name + str(res))if str(res) == "None":logging.warning(room_name + ":拉取zhiyan_data:" + metric_name + " 出现了问题,拉取数据为None")return 0else:return res
else:return 0
2、再加上的条件判断,保护免受不符合 HTTP 标准的 URL 的侵害
if (response.status_code != 204 andresponse.headers["content-type"].strip().startswith("application/json")
):