我有一个脚本可以在 Twitter 上搜索某个词,然后为返回的结果打印出一些属性。
我正在尝试只返回一个空白数组。任何想法为什么?
public_tweets = api.search("Trump")
tweets_array = np.empty((0,3))
for tweet in public_tweets:
userid = api.get_user(tweet.user.id)
username = userid.screen_name
location = tweet.user.location
tweetText = tweet.text
analysis = TextBlob(tweet.text)
polarity = analysis.sentiment.polarity
np.append(tweets_array, [[username, location, tweetText]], axis=0)
print(tweets_array)
我试图实现的行为类似于..
array = []
array.append([item1, item2, item3])
array.append([item4,item5, item6])
array
现在是[item1, item2, item3],[item4, item5, item6]
。
但是在 Numpy 中:)