最近在Windows10上为EclipseOxygen3安装了PyDev。作为一个新的程序员,我在写一本“学习代码”的书时正在编写基本程序。我正在处理的示例使用了一个名为“snaps”的模块,它位于“pygame”中。下面的程序在pythonshellide中运行良好。在
import snaps
temp = snaps.get_weather_temp(latitude=47.61, longitude=-122.33)
print('The temperature in Seattle is:', temp)
输出:西雅图的温度是:60
但是当我在PyDev中运行这个时,我得到:
^{pr2}$我已经确认Python路径在windows中设置正确,PyDev解释器也设置正确。我已经添加了每个库,脚本文件夹等,我可以在项目和透视首选项下。我甚至把pygame文件夹添加到了我的工作区。但我还是有错误。在
我已经通过help()函数确认了“get_weather_temp”在snaps模块中,它在IDE中工作,只是在PyDev中不起作用。在
如有任何帮助,将不胜感激。在
我想this可能对你有帮助。如果我没搞错的话,PyDev需要被告知在哪里可以找到安装它的“模块”/“库”,IDE使用默认值,PyDev将使用自己的环境。(下面的代码片段来自评论)如果你有任何问题,只要问-它就可以开始了,你只需要把你自己的api密钥。 (它默认为kelvin,所以您必须转换为f或c,我没有花时间,如果您想这样做,我找到了一个示例here)
如果您好奇,this也是json响应的样子。 输出结果如下:西雅图的当前温度为284.02
决定尝试转换——使用pyowm库要容易得多。 输出结果看起来像“西雅图当前的温度是51.57”,我把变量设置得很愚蠢,这样你就可以跟着做了。在
^{pr2}$相关问题 更多 >
编程相关推荐