天气问题-从天气导入天气,单位ImportError:无法从“天气”导入名称“天气”

我收到此错误:

从天气导入天气,单位ImportError:无法导入名称 “天气”从“天气” (C:Users \ Python \ Python37 \ site-packages \ weather__init __。py)

我已使用pip安装了Weather,但仍然出现错误。我正在尝试安装weather-api,但没有找到weather-api的匹配发行版。

from weather import Weather,Unit
import time

class WeatherData:
temperature = 0
weather_conditions = ''
wind_speed = 0
city = ''

def __init__(self,city):
    self.city = city
    weather = Weather(unit = Unit.CELSIUS)
    lookup = weather.lookup_by_location(self.city)
    self.temperature = lookup.condition.temp
    self.weather_conditions = lookup.condition.text
    self.wind_speed = lookup.wind.speed

def getTemperature(self):
    return self.temperature + " C"

def getWeatherConditions(self):
    return self.weather_conditions

def getWindSpeed(self):
    return self.wind_speed + " kph"

def getcity(self):
    return self.city

def getTime(self):
    return time.ctime()
if __name__ == "__main__":
current_weather = WeatherData('London')
print(current_weather.getTemperature())
print(current_weather.getWeatherConditions())
print(current_weather.getTime())
nihaoguduzi 回答:天气问题-从天气导入天气,单位ImportError:无法从“天气”导入名称“天气”

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2753948.html

大家都在问