我试图制作一个简单的脚本,告诉我Twitter帐户何时有新的推文。
import urllib
def CurrentP(array, string):
count = 0
for a_ in array:
if a_ == string:
return count
count = count + 1
twitters = ["troyhunt", "codinghorror"]
last = []
site = "http://twitter.com/"
for twitter in twitters:
source = site+twitter
for line in urllib.urlopen(source):
if line.find(twitter+"/status") != -1:
id = line.split('/')[3]
if id != last[CurrentP(twitters,twitter)]:
print "[+] New tweet + " + twitter
last[CurrentP(twitters,twitter)] = id
但是当我尝试运行脚本时出现此错误
File "twitter.py", line 16 in ?
for line in urllib.urlopen(source):
TypeError: iteration over non-sequence
我做错了什么?