【发布时间】:2017-02-15 19:01:13
【问题描述】:
我正在尝试将所有搜索结果放在一个列表中。
代码如下:
cursor = tweepy.Cursor(api.search_users,"foo")
count = 0
for u in cursor.items(30):
count += 1
print count, u.id_str
print count
唉,第 1 项与 21 相同,第 2 项与 22 相同 &c:
1 19081001
2 313527365
3 89528870
4 682463
5 2607583036
6 219840627
7 725883651280363520
8 371980318
9 860066587
10 4794574949
11 88633646
12 137482245
13 1447284511
14 15369494
15 171657474
16 442113112
17 6130932
18 2587755194
19 191338693
20 528804165
21 19081001
22 313527365
23 89528870
24 682463
25 2607583036
26 219840627
27 725883651280363520
28 371980318
29 860066587
30 4794574949
30
我如何获得所有搜索结果?
根据要求:
dir(cursor)
['__class__',
'__delattr__',
'__dict__',
'__doc__',
'__format__',
'__getattribute__',
'__hash__',
'__init__',
'__module__',
'__new__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__setattr__',
'__sizeof__',
'__str__',
'__subclasshook__',
'__weakref__',
'items',
'iterator',
'pages']
【问题讨论】:
-
试试
dir(cursor)看看你能用它做什么。如果你没有发现任何令人惊奇的东西,它必须是一个 pythonic 解决方案。 -
我将它添加到问题文本中,但我看不出这与 repeated 输出有何关联。
-
你想达到什么目的?您能否在问题中清楚地添加要求!
-
@kmario23:我正在尝试将所有搜索结果放在一个列表中。我不认为这是相关的。我不应该看到重复的条目。
-
我发现了这个问题。你能试试我的答案吗?