def pluglistafamilia():
data = connect('GET', '/plugins/families')
return list((h['id']) for h in data['family'])
def getfamilia():
data = connect('GET', '/plugins/families')
return dict((h['count'], h['name'], h['id']) for h in data['family'])
if __name__ == '__main__':
token = login(username, password)
d = getfamilia()
print d
当我试图打印列表或词典时,收到以下错误消息。我知道我的语法可能错了。我还是个初学者。你知道吗
TypeError: list indices must be integers, not str
如果不知道您使用的是什么API,就无法判断您在哪个部分出错。听起来
data
或h
是一行中的列表:然而,当你开始工作的时候,你也会遇到另一个问题。你知道吗
我不知道你的字典应该是什么样子,但你更适合做一个dict comp。你知道吗
相关问题 更多 >
编程相关推荐