ImportError:无法导入名称' OAuthHandler'

时间:2017-07-21 16:19:05

标签: python python-3.x twitter tweepy

import tweepy

consumerKey = "MGjdrqvqer1hSiQcmKp6Oxwea"
consumerSecret = "vGKoEvJdpooSSn8a0lh4Fp51fFX6wK6qoRzx8QJvPEAecAg6mE"

auth = tweepy.OAuthHandler(consumerKey,consumerSecret)

accessToken = "886183447596638209-gu896OPrhbiW1IlUft7kwvkalrEgMTE"
accessTokenSecret = "kqmMkSKg0sa8DGzPOi8WbHlpMGghi8STj6M3ofo9XLx18"

auth.set_access_token(accessToken, accessTokenSecret)

api = tweepy.API(auth)


tweet = " ABCDE "
api.update_status(status=tweet)

print("Success")
print()

我把它弄坏了,但每次都会出现错误。 我重新安装它,但它变得越来越好。

1 个答案:

答案 0 :(得分:1)

您可以尝试直接从OAuthHandler

导入tweepy.auth属性
from tweepy.auth import OAuthHandler

consumerKey = "MGjdrqvqer1hSiQcmKp6Oxwea"
consumerSecret = "vGKoEvJdpooSSn8a0lh4Fp51fFX6wK6qoRzx8QJvPEAecAg6mE"

auth = OAuthHandler(consumerKey, consumerSecret)

accessToken = "886183447596638209-gu896OPrhbiW1IlUft7kwvkalrEgMTE"
accessTokenSecret = "kqmMkSKg0sa8DGzPOi8WbHlpMGghi8STj6M3ofo9XLx18"

auth.set_access_token(accessToken, accessTokenSecret)