首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AttributeError:“模块”对象没有属性“get_altitude”

AttributeError:“模块”对象没有属性“get_altitude”
EN

Stack Overflow用户
提问于 2016-01-03 21:50:42
回答 1查看 396关注 0票数 2

我的pysolarrobot7.py代码的这一部分是抛出一个AttributeError

代码语言:javascript
复制
def tomorrow_heading():
    increment_min = 1
    incrementeddatetime = 0
    tomorrow_corrected = 90
    if pysolar.get_altitude(maplat, maplon, datetime.datetime.utcnow()) < 0:
        while pysolar.get_altitude(maplat, maplon, (datetime.datetime.utcnow() + datetime.timedelta(minutes=incrementeddatetime))) < 0:
          incrementeddatetime = incrementeddatetime + increment_min
        sunrise_time=(datetime.datetime.utcnow() + datetime.timedelta(minutes=incrementeddatetime))
        tomorrow_heading = pysolar.GetAzimuth(maplat, maplon, sunrise_time)
        if tomorrow_heading < 0:
            if (tomorrow_heading >= -180):
                tomorrow_corrected = ((tomorrow_heading * -1) + 180)
            if (tomorrow_heading < -180):
                tomorrow_corrected = ((tomorrow_heading * -1) - 180)
        if tomorrow_heading >= 0:

以下是错误代码

代码语言:javascript
复制
root@Primerpi:/tools# python3 solarrobot7-core.py

Traceback (most recent call last):
  File "solarrobot7-core.py", line 237, in <module>
    tomorrow_static = tomorrow_heading()
  File "solarrobot7-core.py", line 176, in tomorrow_heading
    if pysolar.get_altitude(maplat, maplon, datetime.datetime.utcnow()) < 0:
AttributeError: 'module' object has no attribute 'get_altitude'

我已经搜索了一段时间了,似乎找不到答案。solarrobot7.py的原始代码使用了GetAltitudePysolar (PascalCase),我将其更改为get_altitudepysolar (snake_case)。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-01-03 22:01:56

pysolar没有一个"get_altitude“方法:你想要子模块”太阳“:)

代码语言:javascript
复制
from pysolar import solar
solar.get_altitude #this will work :)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34582018

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档