我正在解析器中工作。异常后循环中断。需要您的帮助
def requestBarter():
response = requests.get(api url)
return response.json();
def responsePrint(id, json_data):
title = json_data[id]["title"]
tradable = json_data[id]["tradable"]
wishlist = json_data[id]["wishlist"]
library = json_data[id]["library"]
bundles = json_data[id]["bundles"]
cards = json_data[id]["cards"]
userreviews = json_data[id]["userreviews"]
print("ID: " + id + " | Titile: " + title + " | Tradable: " + str(tradable) + " | Wishlist: " + str(
wishlist) + " | Library: " + str(
library) + " | Bundles: " + str(bundles) + " | Cards: " + str(cards) + " | Userreviews: " + str(userreviews))
def responsePrintOnException(id, json_data):
title = json_data[id]["title"]
tradable = json_data[id]["tradable"]
wishlist = json_data[id]["wishlist"]
library = json_data[id]["library"]
bundles = json_data[id]["bundles"]
cards = json_data[id]["cards"]
print("ID: " + id + " | Titile: " + title + " | Tradable: " + str(tradable) + " | Wishlist: " + str(
wishlist) + " | Library: " + str(
library) + " | Bundles: " + str(bundles) + " | Cards: " + str(cards))
def getAll():
try:
json_data = requestBarter()
for id in json_data:
responsePrint(id, json_data)
except KeyError:
responsePrintOnException(id, json_data)
pass
if __name__ == '__main__':
getAll()
KeyError退出循环后,因此需要以下代码的帮助 预计超过90000条线。实际输出-30