1、报错原因及详情
这个报错原因很明显,是因为给了一个空对象给JSON解析,故此报错
详细报错信息如下:
Traceback (most recent call last):
File "/home/admin/apps/*-*-sync/task/__init__.py", line 114, in run
for data in self.index_data():
File "/home/admin/apps/*-*-sync/task/huahuo/*_*_sync.py", line 72, in index_data
data = self.make_field_true(results)
File "/home/admin/apps/*_*-sync/task/huahuo/*_*_sync.py", line 57, in make_field_true
data['price_infos'] = json.loads(result['price_infos'])
File "/usr/local/python36/lib/python3.6/json/__init__.py", line 348, in loads
'not {!r}'.format(s.__class__.__name__))
TypeError: the JSON object must be str, bytes or bytearray, not 'NoneType'
2、源码截图如下:
3、解决办法
只需要加一个判空处理即可
改变后的源码如下: