输入接口返回值,然后得到一个含有所有参数名称的列表

63 阅读1分钟

class Do():
all = []
def deep(self,A, xpath=r”“):
‘结构不同画叉报错(可设置),找不到画叉不报错,仅内容不同’
if isinstance(A, list):
for i in range(len(A)):
if isinstance(A[i],list):
self.deep(A[i],xpath+r”[%s]”%(i))
elif isinstance(A[i],dict):
self.deep(A[i], xpath + r”[%s]”%i)
else:
pass
if isinstance(A, dict):
for i in A.keys():
if isinstance(A.get(i),dict):
self.all.append(xpath+r”[‘%s’]” %i)
self.deep(A.get(i),xpath+r”[‘%s’]”%i)
elif isinstance(A.get(i),list):
self.all.append(xpath +r”[‘%s’]” %i)
self.deep(A.get(i), xpath + r”[‘%s’]” % i)
else:
self.all.append(xpath+r”[‘%s’]” % i)

可以用来做接口参数遍历