pytest_api/tools/jsonpath_date_replace.py

15 lines
388 B
Python

#!/usr/bin/python3
# -*- coding: utf-8 -*-
def jsonpath_replace(change_data, key_name):
"""处理jsonpath数据"""
_new_data = key_name + ''
for i in change_data:
if i == '$':
pass
elif i[0] == '[' and i[-1] == ']':
_new_data += "[" + i[1:-1] + "]"
else:
_new_data += "[" + "'" + i + "'" + "]"
return _new_data