当我运行程序时,它会抛出错误,并在vs代码中给出“错误:location.condition为“不可调用”

2021-09-27 06:53:23 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用python构建一个助手。它一直在显示错误 "位置、条件不可调用pylint(不可调用)“&;”位置.预测“不可调用pylint(不可调用)”

    elif 'current weather in' in command:   
        reg_ex = re.search('current weather in (.*)', command)
        if reg_ex:
            city = reg_ex.group(1)
            weather = Weather(unit=Unit.CELSIUS)
            location = weather.lookup_by_location(city)
            condition = location.condition()
            TalkToMe('The Current weather in %s is %s.' 
            'The tempeture is %d.1 C degree' %(city, condition.text(), 
               (int(condition.temp))))

    elif 'weather forecast in' in command:
        reg_ex = re.search('weather forecast in (.*)', command)
        if reg_ex:
            city = reg_ex.group(1)
            weather = Weather()
            location = weather.lookup_by_location(city)
            forecasts = location.forecast()
            for i in range(0,3):
                TalkToMe("On %s will it %s."
                'The maximum temperture will be %d.1 C degree.'
                'The lowest temperature will be %d.1 C degrees.' % (forecasts[i].date(), forecasts[i].text(), (int(forecasts[i].high)), (int(forecasts[i].low))))

它应该告诉天气状况或天气预报