我正在用Python编写一个程序,它使用Twitter的API,它在Twitter上搜索关于我们想要的任何主题的tweet列表,然后分析每条tweet,看看它的情绪是积极还是消极。 一开始我用for loop在cmd中打印出tweets。程序中循环的初始代码
api = tweepy.API(auth)
public_tweets = api.search("Estonia")
for tweet in public_tweets:
print(tweet.text.encode("utf-8"))
analysis = TextBlob(tweet.text)
print(analysis.sentiment)
现在我想用csv直接写入一个文本文件,但是出现了一个错误 代码:
^{pr2}$错误
C:\Users\ArturErik\Desktop>python sentiment.py
Traceback (most recent call last):
File "sentiment.py", line 23, in <module>
scoreFileWriter.writerow([text, sentiment])
io.UnsupportedOperation: not writable
我是Python新手,我无法修复这个bug。在
你试过用吗
相关问题 更多 >
编程相关推荐