好的,请注意这是我的第一篇文章
所以,我正在尝试使用Python来获取Twitter趋势,我正在使用python 2.7和Tweepy.
我想要这样的东西(有效):
#!/usr/bin/python
# -*- coding: utf-8 -*-
import tweepy
consumer_key = 'secret'
consumer_secret = 'secret'
access_token = 'secret'
access_token_secret = 'secret'
# OAuth process, using the keys and tokens
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
trends1 = api.trends_place(1)
print trends1
Run Code Online (Sandbox Code Playgroud)
这给了一个巨大的JSON字符串,
我想将每个趋势名称提取为一个变量,str(trendsname)理想情况下是字符串格式.
trendsname = str(trend1) + " " +str(trend2) + " "
对于每个趋势名称,哪个理想情况下会有如此趋势的名称:
等等.
请注意我只学习Python.