我在嵌套的for循环中使用相同的键和不同的两个不同的api调用的不同值从api json响应中解析键及其值时遇到问题
我能够从api调用中获取键和值,但是第二个具有相同键但值不同的api调用出现问题,抛出键错误
def classtest(self):`enter code here`
apione = http://jira.com/rest/1
apitwo = https://jira.com/rest/2
apithree = https://jira.com/rest/3
requestglobal = requests.request("GET", apione, content-type=application/json)
responseglobal = requestglobal.getResponse()
for i in responseglobal['issues']:
issue1 = i[key]
print(issue1)
requesttwo = requests.request("GET", apithree, content-type=application/json)
responsetwo = requestone.getResponse()
for i in responsetwo['issues']:
issue2 = i[key] + str(issue1)
print(issue2)
requestthree = requests.request("GET", apitthree, content-type=application/json)
responsethree = requestthree.getResponse()
for i in responsethree['issues']:
issue3 = i[key] + str(issue2)
print(issue3)
print("something from second loop")
print ("something from first for loop")
现在它可以用于第一个呼叫,但是在第二个呼叫抛出keyError
时失败,它应该同时返回issue1和issue2值。