Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
试图访问多伦多趋势的“名称”部分。到目前为止,我有这个,但它给了我错误:
toronto = t.get_place_trends(id=4118) trend_array = [] for trend in toronto.trends.name: trend_array.append(trend) print trend_array print trend
那是在身份验证之后并返回强制进入数组(由于某种原因无法通过索引访问)并作为列表的整个对象列表。
哇,toronto返回一个必须通过索引访问的列表真的很奇怪。
toronto
这是您需要的代码:
toronto = t.get_place_trends(id=4118) trend_array = [] if toronto: for trend in toronto[0].get('trends', []): trend_array.append(trend['name']) print trend_array print trend