PORT 8080 / IP 0000 cloud09 python

时间:2018-01-27 20:32:50

标签: python cloud9

我正在使用cloud9在python中处理我的第一个程序,我连接到twitter API并进行情绪分析,但是当我运行代码时,我遇到了这个问题:

Your code is running at https://x-x.c9users.io.
Important: use os.getenv(PORT, 8080) as the port and os.getenv(IP, 0.0.0.0) as the host in your scripts!

  File "/home/ubuntu/workspace/demo.py", line 23
SyntaxError: Non-ASCII character '\xd8' in file /home/ubuntu/workspace/demo.py on line 23, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

在我查看了一些解决方案之后,这是我的代码,但我仍然遇到同样的问题:

import os
import tweepy
from textblob import TextBlob

port = os.getenv('PORT', '8080')
host = os.getenv('IP', '0.0.0.0')

# Step 1 - Authenticate
consumer_key= 'xx'
consumer_secret= 'xx'

access_token='xx'
access_token_secret='xx'

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)

api = tweepy.API(auth)

#Step 3 - Retrieve Tweets
public_tweets = api.search('school')

for tweet in public_tweets:

    print(tweet.text)
    analysis = TextBlob(tweet.text)
    print(analysis.sentiment)
    print("")

我还尝试过一种名为" Flask"但没有改变。 谢谢

0 个答案:

没有答案