我不知道为什么会发生此错误,因为.Api是重要的命令

时间:2020-09-02 16:32:46

标签: python api twitter

我正在尝试使用一个名为Api的属性,而PyCharm却无法识别它(它在几分钟前就可以正常工作了)(我试图重新安装该软件包,但没有起作用)

import twitter
def auth():
    api = twitter.Api(consumer_key='key',
                      consumer_secret='secret',
                      access_token_key='key',
                      access_token_secret='secret')
    return api


def get_msg():
    api = auth()
    response = api.GetSearch(term='CBLoL')
    for r in response:
        print(r)


if __name__ == '__main__':
    get_msg()

错误:

"C:\Users\Xtrike\PycharmProjects\Twitter Project\venv\Scripts\python.exe" C:/Users/Xtrike/PycharmProjects/Testes/TT.py
Traceback (most recent call last):
  File "C:/Users/Xtrike/PycharmProjects/Testes/TT.py", line 14, in <module>
    get_msg()
  File "C:/Users/Xtrike/PycharmProjects/Testes/TT.py", line 9, in get_msg
    api = auth()
  File "C:/Users/Xtrike/PycharmProjects/Testes/TT.py", line 3, in auth
    api = twitter.Api(consumer_key='consumer key',
AttributeError: module 'twitter' has no attribute 'Api'

Process finished with exit code 1

0 个答案:

没有答案