这样就可以了!
我建议您使用Python的csv。打开一个文件并在循环期间将其写入,如下所示:
#!/usr/bin/pythonimport tweepyimport csv #import csvauth = tweepy.auth.OAuthHandler('XXXXXX', 'XXXXXXX')auth.set_access_token('XXX-XXX', 'XXX')api = tweepy.API(auth)# Open/create a file to append data tocsvFile = open('result.csv', 'a')#Use csv writercsvWriter = csv.writer(csvFile)for tweet in tweepy.Cursor(api.search, q = "google", since = "2014-02-14", until = "2014-02-15", lang = "en").items(): # Write a row to the CSV file. I use enpre UTF-8 csvWriter.writerow([tweet.created_at, tweet.text.enpre('utf-8')]) print tweet.created_at, tweet.textcsvFile.close()
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)