def findComponent(tree, component):
for key, value in tree.items():
if isinstance(value, dict):
if key == component:
componentDict = dumps({component: deepcopy(value)})
!!!!!! print(componentDict)
!!!!!! return componentDict
findComponent(value, component)
else:
if key == component:
componentDict = dumps({component: value})
print(componentDict)
return componentDict
def main():
args = setupArgparse()
if args.uid and args.component:
res = get('http://localhost:5000/rest/firmware/' + args.uid).json()
test = findComponent(res, args.component)
!!!!!! print(test)
else:
res = get('http://localhost:5000/rest/firmware').json()
print(findComponent(res, "uids"))
if __name__ == '__main__':
main()
我的问题在于这两行。我的打印可以打印正确的json,但是当我返回它并想再次在我的主屏幕中打印时,它会打印“无”]
在此行: