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

查看:29
本文介绍了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".代码实际上运行良好,没有错误并产生预期的结果.我用谷歌搜索并找到如何解决未定义的变量错误,但这似乎是一个黑客回合.总之,该链接表示将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天全站免登陆