python writerows:错误:迭代期望,而不是datetime.datetime

时间:2017-12-09 22:15:02

标签: python list csv twitter tweets

我正在尝试将包含推文的列表保存到csv文件中。这是我的代码:

def get_all_tweets(screen_name):
all_tweets=[]
for page in Cursor(api.user_timeline, screen_name=screen_name,count=5).pages(1):
    for status in page:
        outtweets = ([screen_name, status.created_at, status.text.encode('utf-8'),status.user.location, status.lang]) #for tweet in status]
        all_tweets.extend(outtweets)
        with open('tweets1_DB_SS.csv','w',encoding='utf-8') as f:
            writer = csv.writer(f)
            writer.writerows(all_tweets)

我收到以下错误:

    ---> 12                 writer.writerows(all_tweets)

Error: iterable expected, not datetime.datetime

知道怎么解决吗?

0 个答案:

没有答案