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

来源:互联网 发布:室内水电设计软件 编辑:程序博客网 时间:2024/06/05 06:27

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)

可以用来做接口参数遍历

阅读全文
0 0
原创粉丝点击