when i run the program it throws error and in vs code it is giving "error:location.condition is not callable"
when i run the program it throws error and in vs code it is giving "error:location.condition is not callable"
我正在尝试使用 python 构建一个助手。它一直显示错误
"location.condition is not callable pylint(not-callable)" & "location.forecast is not callable pylint(not-callable)"
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))))
它应该告诉天气状况或天气预报
https://pypi.org/project/weather-api/ 处的示例显示:
weather = Weather(unit=Unit.CELSIUS)
location = weather.lookup_by_location('dublin')
condition = location.condition
print(condition.text)
然而,你正在做 lookup.condition()
。括号导致 Python 到 "call" lookup.condition
,即要求它是可调用的。
请注意,pylint 是一个静态代码分析器。它会尝试提前警告您代码中的问题,因此您可以在实际 运行 程序之前修复它们。静态代码分析器并不总是正确的,但在这种情况下似乎是正确的。删除括号应该可以解决问题。
我正在尝试使用 python 构建一个助手。它一直显示错误 "location.condition is not callable pylint(not-callable)" & "location.forecast is not callable pylint(not-callable)"
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))))
它应该告诉天气状况或天气预报
https://pypi.org/project/weather-api/ 处的示例显示:
weather = Weather(unit=Unit.CELSIUS)
location = weather.lookup_by_location('dublin')
condition = location.condition
print(condition.text)
然而,你正在做 lookup.condition()
。括号导致 Python 到 "call" lookup.condition
,即要求它是可调用的。
请注意,pylint 是一个静态代码分析器。它会尝试提前警告您代码中的问题,因此您可以在实际 运行 程序之前修复它们。静态代码分析器并不总是正确的,但在这种情况下似乎是正确的。删除括号应该可以解决问题。