forked from DxvLwRYF/apiAutoTest
使用json.loads讲请求参数转成json,相比eval在数据量大的时候提升性能,并且目前大部分后端语言中都是用的null,true,false
This commit is contained in:
parent
9afbb31fdf
commit
a32645c04e
|
@ -62,12 +62,11 @@ class DataProcess:
|
|||
return
|
||||
for i in re.findall('&(.*?)&', variable):
|
||||
variable = variable.replace(f'&{i}&', str(extractor(cls.response_dict, i)))
|
||||
if 'null' in variable:
|
||||
variable = variable.replace('null', 'None')
|
||||
if 'true' in variable:
|
||||
variable = variable.replace('true', 'True')
|
||||
if 'false' in variable:
|
||||
variable = variable.replace('false', 'False')
|
||||
if 'None' in variable:
|
||||
variable = variable.replace('None', 'null')
|
||||
if 'True' in variable:
|
||||
variable = variable.replace('True', 'true')
|
||||
if 'False' in variable:
|
||||
variable = variable.replace('False', 'false')
|
||||
logger.info(f'最终的请求数据如下: {variable}')
|
||||
print(variable)
|
||||
return eval(variable)
|
||||
return json.loads(variable)
|
||||
|
|
Loading…
Reference in New Issue