tweepy“未定义变量"错误 [英] tweepy "undefined variable" errors

查看:112
本文介绍了tweepy“未定义变量"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是python和Aptana的新手.

I am new to both python and Aptana.

我正在尝试在python中使用tweepy包.我有以下代码(来自 python的网站):

I am trying to use the tweepy package in python. I have the following code (from python's site):

import tweepy

user = tweepy.api.get_user('twitter') # "undefined variable" error occurs on this line
print user.screen_name
print user.followers_count
for friend in user.friends():
    print friend.screen_name

我得到一个导入时未定义的变量:get_user".该代码实际上运行良好,没有错误,并产生了预期的结果.我用Google搜索并找到如何解决未定义的变量错误,但似乎是一轮hack.总之,该链接表示要在首选项中将"get_user"添加到全局变量.

I get an "Undefined variable from import: get_user". The code actually runs fine with no errors and produces the expected results. I googled and found how to resolve the undefined variable error, but it seems like a hack-a-round. In sum, that link says to add "get_user" to globals in the preferences.

对于Python和Aptana来说都是新手,我只是想检查一下这是否是解决问题的最佳方法....看起来就像是黑客.当我将"tweepy.api.get_user"更改为"tweepy.api.public_timeline"时,我遇到相同的错误,因此必须手动将"public_timeline"添加到全局变量中.您必须手动配置每个变量.

Being new to both Python and Aptana, I just wanted to check to see if that is the best way to resolve it....it just seems like a hack. When I change "tweepy.api.get_user" to "tweepy.api.public_timeline" I get the same error and thus will have to manually add "public_timeline" to the globals....It doesn't seem like the correct way when you have to manually configure each variable.

谢谢!

推荐答案

如果不希望对此有所警告,则可以排除以下警告:

If you would like to not be warned about this you may exclude the warning:

转到窗口->首选项-> PyDev->编辑器->代码分析

goto Window -> Preferences -> PyDev -> Editor -> Code Analysis

单击未定义"选项卡,然后将get_user添加到文本框中.这将清除您的警告.

Click on the Undefined tab and add get_user to the textbox. That will clear up your warning.

安德鲁

这篇关于tweepy“未定义变量"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆