allReqs = getReqs(searchQuest, emptyList)
toDoList = []
for x in allReqs:
questData = next((i for i in response.json()['quests'] if i['title']== allReqs[allReqs.index(x)]),None)
data = OrderedDict()
for key in ('title','status','difficulty','members','questPoints','userEligible'):
data[key] = questData.get(key,'')
#print(json.dumps(data,indent=4))
#print(data['status'])
if data['status'] == "NOT_COMPLETED":
toDoList.append(data['title'] + "REDDD")
elif data['status'] == "COMPLETED":
toDoList.append(data['title'] + "GREENNN")
else:
print("something broke")
错误消息: ['RoughGREENNN中的钻石'] ['RoughGREENNN中的钻石','偷来的鬼魂''] Traceback(最近一次调用最后一次): 文件“questing.py”,第58行,in data [key] = questData.get(key,'') AttributeError:'NoneType'对象没有属性'get'
任何想法如何解决这个问题?如果需要,我可以发布更多代码。
我正在尝试搜索名称列表,根据json
响应进行检查,如果找到了'title'
,请检查'status'
并根据{{1}的值将它们附加到另一个将在末尾打印的列表中。
谢谢!